Skip if no hrefs
Anirudh Oppiliappan x@icyphox.sh
Sat, 03 Apr 2021 16:28:37 +0530
1 files changed,
5 insertions(+),
2 deletions(-)
jump to
M
app/html.py
→
app/html.py
@@ -25,8 +25,11 @@ def fetch_page(url):
res = requests.get(url) soup = BeautifulSoup(res.content, "lxml") for a in soup.find_all("a"): - if not is_absolute_url(a["href"]): - a["href"] = urllib.parse.urljoin(url, a["href"]) + try: + if not is_absolute_url(a["href"]): + a["href"] = urllib.parse.urljoin(url, a["href"]) + except KeyError: + pass return {"title": soup.title.string, "html": str(soup.html)}