【发布时间】:2018-10-03 21:08:04
【问题描述】:
我正在尝试使用 Python 解析 HTML 源代码。我为此目的使用BeautifulSoup。我需要得到的是以nameX 格式获取所有td 标签,其中X 从1 开始。所以它们是name1, name2, ...,与我们拥有的一样多。
我怎样才能做到这一点?我使用正则表达式的简单代码不起作用。
soup = BeautifulSoup(response.text,"lxml")
resp=soup.find_all("td",{"id":'name*'})
错误:
IndexError: list index out of range
【问题讨论】:
标签: python python-3.x beautifulsoup html-parsing string-parsing