import requests
from bs4 import BeautifulSoup
def get_actors():
actor_list = []
for i in range(0,10):
link = "http://movie.douban.com/top250?start="+str(i*25)
header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 SE 2.X MetaSr 1.0","Host":"movie.douban.com" }
response = requests.get(link,headers = header)
#print(response.status_code)
soup = BeautifulSoup(response.text,"html.parser")
div_list = soup.find_all('div',class_='bd')
for each in div_list:
actor = each.p.text.strip()
actor_list.append(actor)
return actor_list
actors = get_actors()
print(actors)
第一个爬虫:获取演员表
FrankHuang8882024-04-27 15:07
相关推荐
985小水博一枚呀6 小时前
【对于Python爬虫的理解】数据挖掘、信息聚合、价格监控、新闻爬取等,附代码。大神薯条老师8 小时前
Python从入门到高手5.1节-Python简单数据类型镜花照无眠12 小时前
Python爬虫使用实例-mdrama小白学大数据19 小时前
User-Agent在WebMagic爬虫中的重要性大神薯条老师1 天前
Python从入门到高手4.3节-掌握跳转控制语句wdxylb2 天前
Pyhton爬虫使用Selenium实现浏览器自动化操作抓取网页菜鸡中的奋斗鸡→挣扎鸡2 天前
初始爬虫11凡人的AI工具箱2 天前
15分钟学 Python 第35天 :Python 爬虫入门(一)新缸中之脑2 天前
ScrapeGraphAI 大模型增强的网络爬虫易辰君2 天前
python爬虫 - 初识爬虫