def scrape_web(website):
r = requests.get(website, timeout=5)
tree = html.fromstring(r.content)
rss_links = tree.xpath('//link[@rel="alternate" and @type="application/atom+xml"]/@href')
if len(rss_links) == 0:
raise NoLinkError(website)
else:
return urllib.parse.urljoin(website, rss_links[0])
评论列表
文章目录