第一个爬虫:获取演员表

复制代码
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)
相关推荐
跨境数据猎手11 小时前
Superbuy淘宝代购集运系统架构拆解,复刻方案参考
爬虫·架构·系统架构
Smartdaili China2 天前
OpenClaw赋能AI智能体:实时联网与网页抓取
人工智能·爬虫·ai·爬取·openclaw·open claw
IP搭子来一个2 天前
爬虫使用代理 IP 频繁失效,该如何定位问题?
网络·爬虫·tcp/ip
weixin_468466852 天前
Crawl4Ai 智能数据采集与场景化应用指南
大数据·人工智能·爬虫·python·数据分析
小熊Coding2 天前
Python爬取当当网二手图书项目实战!
开发语言·爬虫·python·beautifulsoup·requests·二手图书
IP搭子来一个3 天前
爬虫采集大量返回 403、429,到底卡在哪一环?
网络·爬虫·python
小白学大数据3 天前
Playwright 爬虫:Python 爬取 JS 渲染的 JSP 网站
开发语言·javascript·爬虫·python·数据分析
遇事不決洛必達3 天前
【爬虫随笔】常见加密算法特征总结
javascript·爬虫·逆向·加密算法
小白学大数据3 天前
电商关键词挖掘:Java 爬虫抓取 1688 推荐搜索词
java·开发语言·爬虫·python
小白学大数据3 天前
浅析爬虫技术更迭:静态请求与浏览器渲染采集能力对比
爬虫·python·spring·数据分析