【发布时间】:2020-11-15 21:31:37
【问题描述】:
我是 python 新手,我正在研究界面。我应该从 imdb 网站获取前 250 部电影。
def clicked(self):
movie=self.movie_name.text()
url="https://www.imdb.com/chart/top/"
response=requests.get(url)
html_content=response.content
soup=BeautifulSoup(html_content,"html.parser")
movie_name = soup.find_all("td",{"class":"titleColumn"})
for i in movie_name:
i=i.text
i=i.strip()
i=i.replace("\n","")
if (movie == i):
self.yazialani.setText(i)
使用此代码输出如下: 6. 辛德勒的名单(1993) 7. 指环王:王者归来(2003) 8. 低俗小说(1994) 但对于我的项目,我只想取电影名称而不是年份和排名。我应该如何更改我的代码?
【问题讨论】:
标签: python html beautifulsoup request