0
在表格中,我正在刮,第二行非常长,我想简单地限制字符因为我只想要字符串开头的信息。我想刮掉其他行。所以我的代码如下:我如何限制for循环中的一个特定表行中的字符(Python/BeautifulSoup)
table = soup.find(id="table3")
table_rows = table.findAll('tr')
for tr in table_rows:
td = tr.findAll('td')
row = [i.text.strip() for i in td]
print(row)
我怎样才能只针对第二行?
输出具体是这样的:
["Computer price for Apple Inc. ,\n\n\nType\nForward\n\n\n\n\n\n\nBack\n\n\n\n\nDie\n\r\n...
所以我只想虎视眈眈的Computer price for Apple Inc.
一部分,也许有比只用字符的限制作为一种启发式的更好的方法。是否可以指定它来抓取所有内容,\n\n\n
谢谢!但是如何在多个页面拼出时将其写出来,每个页面对于不同的公司都有不同的计算机价格。 – Jason
好吧,没关系,想通了,谢谢! – Jason