第一个爬虫:获取演员表

复制代码
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)
相关推荐
用户199701080181 小时前
深入解析淘宝商品详情 API 接口:功能、使用与实践指南
大数据·爬虫·数据挖掘
西柚小萌新4 小时前
【Python爬虫实战篇】--Selenium爬取Mysteel数据
开发语言·爬虫·python
Auroral1564 小时前
【Python爬虫详解】第四篇:使用解析库提取网页数据——XPath
爬虫
Auroral1564 小时前
【Python爬虫详解】第四篇:使用解析库提取网页数据——PyQuery
爬虫
Auroral1564 小时前
【Python爬虫详解】第四篇:使用解析库提取网页数据——BeautifuSoup
爬虫
kadog5 小时前
《Python3网络爬虫开发实战(第二版)》配套案例 spa6
开发语言·javascript·爬虫·python
徒慕风流5 小时前
利用Python爬虫实现百度图片搜索的PNG图片下载
开发语言·爬虫·python
用户199701080187 小时前
深入研究:Shopee商品列表API接口详解
大数据·爬虫·数据挖掘
攻城狮7号7 小时前
Python爬虫第19节-动态渲染页面抓取之Splash使用下篇
开发语言·爬虫·python·python爬虫
用户199701080181 天前
深入研究:Shopee商品详情API接口详解
大数据·爬虫·数据挖掘