我正在使用BeautifulSoup模块以这种方式从html中选择所有href:
def extract_links(html):
soup = BeautifulSoup(html)
anchors = soup.findAll('a')
print anchors
links = []
for a in anchors:
links.append(a['href'])
return links
但有时它失败了这个错误信息:
Traceback (most recent call last):
File "C:\py\main.py",line 33,in
最佳答案
原文链接:https://www.f2er.com/html/426385.html