第一个爬虫:获取演员表

复制代码
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)
相关推荐
小白学大数据2 天前
线上故障急救:依托 OpenClaw 日志排查 403 和 503 问题
爬虫·python·selenium·数据分析
有味道的男人2 天前
利用爬虫获取中国制造网商品详情:高效采集完整方案
爬虫·制造
anew___2 天前
2026年Python爬虫技术完全指南:从入门到实战
开发语言·爬虫·python
深蓝电商API2 天前
无头浏览器性能优化:内存占用从2GB降到200MB
爬虫·性能优化
深蓝电商API2 天前
CDP协议深度解析:不通过WebDriver直接操控浏览器
爬虫
北极星日淘2 天前
Python代理池动态适配日淘爬虫|解决高频抓取IP封禁终极方案(含完整源码)
爬虫·python·tcp/ip
赵大大宝2 天前
Selenium 从入门到精通:自动化测试与爬虫实战全攻略
爬虫·selenium·测试工具
北极星日淘2 天前
Python爬虫断点续爬实战|基于Redis实现日淘商品增量抓取(解决重启全量重爬问题)
redis·爬虫·python
电商API_180079052473 天前
Python 实现闲鱼商品列表批量采集,接口异常重试机制搭建
大数据·开发语言·数据库·爬虫·python
绘梨衣5473 天前
采集基类设计遇到的描述符bug
爬虫·python·bug