第一个爬虫:获取演员表

复制代码
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)
相关推荐
guoyunsky16 小时前
Ins爬虫可以抓取到国家,性别和年龄吗?
爬虫·数据分析·rpa
前端小趴菜~时倾18 小时前
自我提升-python爬虫学习:day03
爬虫·python·学习
Blurpath住宅代理18 小时前
HTTP与SOCKS5代理深度对比:从协议层到实战选型指南
爬虫·http·静态ip·动态代理·住宅ip·住宅代理
前端小趴菜~时倾19 小时前
自我提升-python爬虫学习:day04
爬虫·python·学习
feasibility.1 天前
AI 爬虫高手养成:Openclaw+Scrapling 手动部署 + 采集策略(以Walmart 电商平台为例)
人工智能·爬虫·科技·机器人·agi·openclaw·scrapling
vx_biyesheji00011 天前
Python 全国城市租房洞察系统 Django框架 Requests爬虫 可视化 房子 房源 大数据 大模型 计算机毕业设计源码(建议收藏)✅
爬虫·python·机器学习·django·flask·课程设计·旅游
胡耀超1 天前
Web Crawling 网络爬虫全景:技术体系、反爬对抗与全链路成本分析
前端·爬虫·python·网络爬虫·数据采集·逆向工程·反爬虫
itjinyin2 天前
初级爬虫实战——巴黎圣母院新闻
爬虫
vx_biyesheji00012 天前
计算机毕业设计:Python多源新闻数据智能舆情挖掘平台 Flask框架 爬虫 SnowNLP ARIMA 可视化 数据分析 大数据(建议收藏)✅
爬虫·python·机器学习·数据分析·django·flask·课程设计
j_xxx404_2 天前
爬虫对抗:ZLibrary反爬机制实战分析 (三) - 突破高频访问限制与TLS指纹(JA3)风控
爬虫