Demonoid.urls¶
- class demonoid.urls.Url(base_url=None, path=None, params=None)[source]¶
The Url class handles building urls with a base url, path and params. Also it makes requests to urls and builds a DOM element with lxml. It shouldn’t be used directly.
Attr: DEFAULT_BASE_URL is ‘http://www.demonoid.pw/‘. Changing it directly isn’t recommended. Instead pass a base_url parameter to Url class. - DOM[source]¶
Lazy gets (or builds if needed) a DOM from response’s text of combined url.
Returns: DOM built from response Return type: lxml.HtmlElement
- add_param(key, value)[source]¶
Updates or adds a key`=`value parameter in existing self.params.
Parameters: - key (str) – Parameter name
- value (str) – Parameter value
Returns: self
Return type: Url
- add_params(params)[source]¶
Updates existing self.params with given params.
Parameters: params (dict) – Parameters to add Returns: self Return type: Url
- combine(path)[source]¶
Gives a combined self.BASE_URL with the given path. Used to build urls without modifying the current self.path. Handles conflicts of trailing or preceding slashes.
Parameters: path (str) – path to append Returns: combined self.base_url and given path. Return type: str
- fetch()[source]¶
Makes a request to combined url with self._params as parameters. If the server at combined url responds with Client or Server error, raises an exception.
Returns: the response from combined url Return type: requests.models.Response