我只想从wiki页面上删掉电影标题,请帮我一下。
我的代码:
url = 'https://en.wikipedia.org/wiki/List_of_American_films_of_2020'
page = requests.get(url)
soup = BeautifulSoup(page.content,'html.parser')
movies = soup.find('table',{'class':'wikitable sortable'})
print(movies)我只想从结构中过滤掉电影标题,就像图像中的片名只应该是“丢失的传输”。
发布于 2020-09-01 09:07:42
您可以进一步使用刮过的表。
table_body = movies.find('tbody')
titles = []
rows = table_body.find_all('tr')
for row in rows[1:]: # leaving the first row, seems it is a header
title_cell = row.select("td i a")
titles.append(title_cell[0].contents[0])
print(titles) 发布于 2020-09-01 09:08:54
https://stackoverflow.com/questions/63684246
复制相似问题