第一个爬虫:获取演员表

复制代码
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)
相关推荐
喵手6 小时前
Python爬虫实战:电商问答语料构建完整实战 - 从爬取到检索语料的工程化实现(附CSV导出 + SQLite持久化存储)!
爬虫·python·sqlite·爬虫实战·零基础python爬虫教学·电商问答语料构建·爬取到检索语料
yq19820430115611 小时前
基于Python爬虫原理的Pinterest视频资源获取技术解析与工具实践
爬虫·python·django·音视频
喵手11 小时前
Python爬虫实战:自动化质量护航 - 构建爬虫数据的“熔断与巡检”规则引擎实战!
爬虫·python·自动化·爬虫实战·零基础python爬虫教学·自动化质量护航·数据熔断
嚯嚯歪1 天前
攻克腾讯 TCaptcha 滑块验证码:纯 HTTP 协议逆向实战
爬虫·python·逆向·验证码识别
喵手1 天前
Python爬虫实战:构建一个高健壮性的图书数据采集器!
爬虫·python·爬虫实战·零基础python爬虫教学·构建图书数据·采集图书数据·图书数据采集
喵手1 天前
Python爬虫实战:监控型爬虫实战 - 从结构检测到智能告警的完整方案(附CSV导出 + SQLite持久化存储)!
爬虫·python·爬虫实战·零基础python爬虫教学·csv导出·监控型爬虫实战·从结构哦检测到智能告警
深蓝电商API1 天前
爬虫中 Cookie 池维护与自动刷新
爬虫·python
喵手1 天前
Python爬虫实战:开放数据多格式入仓 - 构建统一数据管道(附CSV导出 + SQLite持久化存储)!
爬虫·python·爬虫实战·零基础python爬虫教学·csv导出·开放数据多格式·统一数据管道
流烟默1 天前
Python爬虫之下载豆瓣电影图片到本地
爬虫·python
喵手1 天前
Python爬虫实战:构建“时光机”——网站数据增量监控与差异分析系统!
爬虫·python·爬虫实战·差异分析·零基础python爬虫教学·网站数据增量·网站数据增量监控系统