第一个爬虫:获取演员表

复制代码
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)
相关推荐
codeboss6 小时前
做网页变更监控,我在“降噪”上踩过的 7 个坑
爬虫·python
MrDJun6 小时前
长期稳定跑网页监控:TLS 指纹、代理选路与请求节流的工程实践
运维·爬虫·python·网络协议·网站监控
巨量HTTP1 天前
Python爬虫动态换IP实战,彻底解决IP403封禁、限流问题(附完整代码)
爬虫·python·tcp/ip·http
hyf3266331 天前
泛程序哪有想象中难!小白跟着走一遍就全懂
前端·爬虫·搜索引擎·seo·蜘蛛池
艾派森1 天前
Web Scraper API vs 自建爬虫:一次真实对比测试,结果让人震惊
爬虫·python·网络爬虫
爱吃提升2 天前
python 分布式爬虫、爬虫合规与综合实战项目
分布式·爬虫·python
亿牛云爬虫专家2 天前
如何设计一套高可用的爬虫任务队列,保证断点续爬与故障转移?
redis·爬虫·故障转移·任务队列·代理ip·requests·隧道代理
二十雨辰3 天前
[爬虫]-Urllib
爬虫·python
深蓝电商API3 天前
gRPC 数据抓取原理详解
爬虫
上海云盾-小余3 天前
全链路多层防护体系,一站式拦截 DDoS、CC、爬虫与注入攻击
网络·爬虫·安全·ddos