MCPcopy Index your code
hub / github.com/clips/pattern / HTMLLinkParser

Class HTMLLinkParser

pattern/web/__init__.py:3056–3081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3054 return self.url > link.url
3055
3056class HTMLLinkParser(HTMLParser):
3057
3058 def __init__(self):
3059 HTMLParser.__init__(self)
3060
3061 def parse(self, html, url=""):
3062 """ Returns a list of Links parsed from the given HTML string.
3063 """
3064 if html is None:
3065 return None
3066 self._url = url
3067 self._data = []
3068 self.feed(self.clean(html))
3069 self.close()
3070 self.reset()
3071 return self._data
3072
3073 def handle_starttag(self, tag, attributes):
3074 if tag == "a":
3075 attributes = dict(attributes)
3076 if "href" in attributes:
3077 link = Link(url = attributes.get("href"),
3078 text = attributes.get("title"),
3079 relation = attributes.get("rel", ""),
3080 referrer = self._url)
3081 self._data.append(link)
3082
3083def base(url):
3084 """ Returns the URL domain name:

Callers 2

__init__Method · 0.85
crawlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…