weboob.browser.url

class weboob.browser.url.URL(*args)

Bases: object

A description of an URL on the PagesBrowser website.

It takes one or several regexps to match urls, and an optional Page class which is instancied by PagesBrowser.open if the page matches a regex.

build(**kwargs)

Build an url with the given arguments from URL’s regexps.

Parameters:param – Query string parameters
Return type:str
Raises:UrlNotResolvable if unable to resolve a correct url with the given arguments.
go(params=None, data=None, method=None, headers=None, **kwargs)

Request to go on this url.

Arguments are optional parameters for url.

>>> url = URL('http://exawple.org/(?P<pagename>).html')
>>> url.stay_or_go(pagename='index')
handle(response)

Handle a HTTP response to get an instance of the klass if it matches.

id2url(func)

Helper decorator to get an URL if the given first parameter is an ID.

is_here(**kwargs)

Returns True if the current page of browser matches this URL. If arguments are provided, and only then, they are checked against the arguments that were used to build the current page URL.

match(url, base=None)

Check if the given url match this object.

open(params=None, data=None, method=None, headers=None, **kwargs)

Request to open on this url.

Arguments are optional parameters for url.

Parameters:data – POST data
>>> url = URL('http://exawple.org/(?P<pagename>).html')
>>> url.open(pagename='index')
stay_or_go(headers=None, **kwargs)

Request to go on this url only if we aren’t already here.

Arguments are optional parameters for url.

>>> url = URL('http://exawple.org/(?P<pagename>).html')
>>> url.stay_or_go(pagename='index')
exception weboob.browser.url.UrlNotResolvable

Bases: exceptions.Exception

Raised when trying to locate on an URL instance which url pattern is not resolvable as a real url.

weboob.browser.url.normalize_url(url)

Normalize URL by lower-casing the domain and other fixes.

Lower-cases the domain, removes the default port and a trailing dot.

>>> normalize_url('http://EXAMPLE:80')
'http://example'