我正在做一个web表抓取任务,以下是我项目的一部分。为什么我只从第一个循环中获得打印结果 - 循环在第一次循环后停止?
from lxml import html
from bs4 import BeautifulSoup
import requests
page = requests.get(link)
tree = html.fromstring(page.text)
web = page.text
soup = BeautifulSoup(web, 'lxml')
table = soup.find_all("table", {"class": "tc_table"})
for tr in table:
tds = tr.find_all('td')
name = tds[1].text
description1 = tds[2].text
description2 = tds[3].text
print(name)
print(description1)
print(description2)