【发布时间】:2021-05-08 11:15:44
【问题描述】:
def search(self, topic, site):
bs = self.getPage(site.searchurl + topic)
searchresults = bs.select(site.resultingList)
for result in searchresults:
url = result.select(site.resulturl)[0].attrs["href"]
if (site.absoluteUrl):
bs = self.getPage(url)
else:
bs = self.getPage(site.url + url)
if bs is None:
print("Something was wrong with that page or URL. Skipping!")
return
title = self.safeGet(bs, site.titleTag)
body = self.safeGet(bs, site.bodyTag)
if title != '' and body != '':
content = Content(topic, title, body, url)
content.print()
在这段代码中是什么意思:
result.select(site.resulturl)[0].attrs["href"]
更具体地说,我无法理解attrs["href"]
【问题讨论】:
标签: python beautifulsoup tags