第一个爬虫:获取演员表

复制代码
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)
相关推荐
深蓝电商API6 小时前
Hook Canvas 获取浏览器指纹
爬虫·hook canvas
深蓝电商API7 小时前
Hook Crypto API 获取加密参数
爬虫·hook crypto api
瓦学妹1 天前
Wikimon Scraper:用 Python 构建数据爬虫
开发语言·爬虫·python
小白学大数据2 天前
长周期爬虫的数据一致性:断点续爬 + 事务回滚保障采集质量
开发语言·爬虫·测试工具
跨境旺仔小拳头2 天前
Wikimon Scraper:用 Python 构建数据爬虫
数据库·爬虫·python
鬼手点金2 天前
Scrapy 网络爬虫框架
爬虫·python·scrapy·ajax·html·json·requsts
正在走向自律2 天前
WorkBuddy AI工具使用介绍完全指南
人工智能·爬虫·ai编程·workbuddy·ai的力量
雨晨源码(同名B站)2 天前
基于Python的网易云音乐评论数据情感化分析系统 音乐爬虫信息可视化 |SnowNLP评论情感分析
开发语言·hadoop·爬虫·python·信息可视化·毕业设计
鬼手点金2 天前
Scrapy + Playwright 完整示例(JS 动态渲染网页)
开发语言·javascript·爬虫·python·scrapy·html·json
zhougl9963 天前
Java Python 爬虫开发比较
java·爬虫·python