第一个爬虫:获取演员表

复制代码
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)
相关推荐
攻城狮7号2 小时前
Python爬虫第21节- 基础图形验证码识别实战
开发语言·爬虫·python·图形验证码识别
顾一大人17 小时前
dp自动化登陆之hCaptcha 验证码
爬虫·python·自动化
whoarethenext20 小时前
c/c++爬虫总结
c语言·c++·爬虫
Dreams°1231 天前
【Python爬虫 !!!!!!政府招投标数据爬虫项目--医疗实例项目文档(提供源码!!!)!!!学会Python爬虫轻松赚外快】
分布式·爬虫·python·mysql·scikit-learn
API小爬虫1 天前
如何用Jsoup库提取商品名称和价格?
java·爬虫
奋斗者1号2 天前
Docker 部署 - Crawl4AI 文档 (v0.5.x)
人工智能·爬虫·机器学习
Clown952 天前
Go语言爬虫系列教程(一) 爬虫基础入门
开发语言·爬虫·golang
火龙谷3 天前
【爬虫】12306查票
爬虫
ζ小菜鸡3 天前
我用Deepseek + 亮数据爬虫神器 1小时做出輿情分析器
爬虫·bright data
q567315233 天前
Go语言多线程爬虫与代理IP反爬
开发语言·爬虫·tcp/ip·golang