第一个爬虫:获取演员表

复制代码
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)
相关推荐
是小崔啊17 小时前
【爬虫】- 爬虫原理及其入门
爬虫
datascome18 小时前
文章发布易优CMS(Eyoucms)网站技巧
数据库·经验分享·爬虫·数据采集·eyoucms·易优cms
傻啦嘿哟1 天前
Python爬虫动态IP代理报错全解析:从问题定位到实战优化
爬虫·python·tcp/ip
用户668578810681 天前
使用 Python 编写一个简单的网页爬虫
爬虫
q567315231 天前
Koa+Puppeteer爬虫教程页面设计
javascript·css·爬虫
傻啦嘿哟2 天前
长效住宅代理IP:反爬虫战场上的隐形盾牌
爬虫·网络协议·tcp/ip
华科云商xiao徐2 天前
冷门但好用的Python库写个爬虫代码
爬虫
华科云商xiao徐2 天前
Koa+Puppeteer爬虫教程页面设计
爬虫
Python×CATIA工业智造2 天前
列表页与详情页的智能识别:多维度判定方法与工业级实现
爬虫·深度学习·pycharm
失败又激情的man3 天前
python之requests库解析
开发语言·爬虫·python