Skip to content

Commit

Permalink
Merge pull request psf#126 from frostming/bugfix/links
Browse files Browse the repository at this point in the history
Fix bugs related to links
  • Loading branch information
kennethreitz committed Mar 11, 2018
2 parents 5b0bfbd + af97ddd commit bcb0881
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions requests_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def gen():

try:
href = link.attrs['href'].strip()
if href and not (href.startswith('#') and self.skip_anchors) and not href.startswith('javascript:'):
if href and not (href.startswith('#') and self.skip_anchors) and not href.startswith('javascript:') and not href.startswith('mailto:'):
yield href
except KeyError:
pass
Expand Down Expand Up @@ -343,15 +343,15 @@ def base_url(self) -> _URL:
# Support for <base> tag.
base = self.find('base', first=True)
if base:
result = base.attrs['href'].strip()
result = base.attrs.get('href', '').strip()
if result:
return result

# Parse the url to separate out the path
parsed = urlparse(self.url)._asdict()

# Remove any part of the path after the last '/'
path = '/'.join(parsed['path'].split('/')[:-1])
parsed['path'] = '/'.join(parsed['path'].split('/')[:-1]) + '/'

# Reconstruct the url with the modified path
parsed = (v for v in parsed.values())
Expand Down

0 comments on commit bcb0881

Please sign in to comment.