absurl() method to build an url in form protocol://domain/path with constant values of Browser
This commit is contained in:
parent
8012afe847
commit
09bb78258a
1 changed files with 7 additions and 0 deletions
|
|
@ -332,6 +332,13 @@ class BaseBrowser(mechanize.Browser):
|
|||
def is_on_page(self, pageCls):
|
||||
return isinstance(self.page, pageCls)
|
||||
|
||||
def absurl(self, rel):
|
||||
if rel is None:
|
||||
return None
|
||||
if not rel.startswith('/'):
|
||||
rel = '/' + rel
|
||||
return '%s://%s%s' % (self.PROTOCOL, self.DOMAIN, rel)
|
||||
|
||||
def follow_link(self, *args, **kwargs):
|
||||
try:
|
||||
self._change_location(mechanize.Browser.follow_link(self, *args, **kwargs))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue