Skip to content
This repository has been archived by the owner on Dec 28, 2020. It is now read-only.

Commit

Permalink
Hyperlink class now parses out the domain as well
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Jul 17, 2014
1 parent 7ff3fc3 commit 02b1b25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions storytracker/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
from six import BytesIO
from bs4 import BeautifulSoup
from .toolbox import UnicodeMixin
try:
from urlparse import urlparse
except ImportError:
from six.moves.urllib.parse import urlparse


class ArchivedURL(UnicodeMixin):
Expand Down Expand Up @@ -160,6 +164,7 @@ class Hyperlink(UnicodeMixin):
def __init__(self, href, contents):
self.href = href
self.contents = contents
self.domain = urlparse(href).netloc

def __unicode__(self):
return six.text_type(self.href)
1 change: 1 addition & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def test_url_hyperlinks(self):
a = obj.hyperlinks[0]
a.href
a.contents
a.domain
a.__unicode__()
a.__str__()
a.__repr__()
Expand Down

0 comments on commit 02b1b25

Please sign in to comment.