第一个爬虫:获取演员表

复制代码
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)
相关推荐
taocarts_bidfans1 天前
Playwright 浏览器指纹伪装 + 住宅代理池 日系电商爬虫防封禁实战
爬虫·bidfans
许彰午1 天前
73_Python爬虫Scrapy框架入门
爬虫·python·scrapy
深蓝电商API1 天前
模拟器批量操控:雷电/夜神 + ADB集群方案
数据仓库·爬虫·adb
许彰午2 天前
72_Python爬虫基础BeautifulSoup
爬虫·python·beautifulsoup
阿标在干嘛2 天前
政策快报爬虫的生存指南:IP池、浏览器模拟、验证码识别实战
爬虫·网络协议·tcp/ip
胡渠洋2 天前
初识python爬虫
爬虫
huangdong_3 天前
电商图片下载工具横向对比深度评测:固乔、FATKUN、图快、当图、淘蛙、存图宝、火蚁一键存图七款工具全面解析
数据库·爬虫
Caco_D13 天前
一行代码抓遍全网 20 个热榜!Aneiang.Pa 4.0 发布 — 极简 .NET 爬虫库
爬虫·.net
太岁又沐风18 天前
复现并修掉ART hook框架 Pine 调用原方法时的偶发 SIGSEGV
爬虫
隔窗听雨眠19 天前
大模型加爬虫上篇:技术融合与架构革新
爬虫·架构