use lxml as the parser and only find links on a page if we've got the source

This commit is contained in:
simon committed 2018-09-09 10:06:25 +01:00
1 parent 738ab8e441
commit 6508156aa4
2 files changed
+3 -8

No files matched your search

+2 -8
View File
@@ -75,7 +75,7 @@ class WebPage(object):
'''
hrefs = set()
soup = BeautifulSoup(self.source, 'html.parser') # handle no source
soup = BeautifulSoup(self.source, 'lxml') # handle no source
links = soup.find_all('a', href=True)
for link in links:
@@ -115,15 +115,9 @@ class WebPage(object):
except Exception as e:
print(e)
try:
if self.source:
self.find_links()
except Exception as e:
print(e)
try:
self.parse_urls()
except Exception as e:
print(e)
class RobotsTxt(object):