【发布时间】:2016-04-18 23:52:33
【问题描述】:
我想从website 中提取某些链接。
为了提取所有链接,我尝试了:
import urllib
import xml.etree.ElementTree as ET
from BeautifulSoup import *
url = 'http://pdok.bundestag.de/index.php?qsafe=&aload=off&q=kleine+anfrage&x=0&y=0&df=22.10.2013&dt=13.01.2016'
uh = urllib.urlopen(url)
data = uh.read()
soup=BeautifulSoup(data)
soup.prettify()
for href in soup.findAll('a'):
print href
现在,我得到了一个链接列表,但由于某种原因,我没有得到tbody 中的重要链接。我也尝试过使用 ElementTree,但我在阅读链接时遇到错误,因为它使用了一些无效符号左右(?)。任何帮助深表感谢! :)
【问题讨论】:
标签: python xml beautifulsoup urllib elementtree