import requests
from bs4 import BeautifulSoup
headers={
"User-Agent":"{Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/115.0"
}
for start_num in range(0,250,25):
# print(start_num)
response = requests.get(f"https://movie.XXX.com/top250?start={start_num}",headers=headers)
html=response.text
soup = BeautifulSoup(html,"html.parser")
all_titles = soup.findAll("span",attrs={"class":"title"})
for title in all_titles:
title_srting = title.string
if "/" not in title_srting:
print(title_srting)
python爬虫requests+BeautifulSoup
最新推荐文章于 2024-09-11 18:01:31 发布