爬虫学习(三)用beautiful 解析html


安装库



py 复制代码
import  requests
from bs4 import BeautifulSoup
headers = {
    "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"

}
for start_num in range(0,250,25):

    response = requests.get(f"https://movie.douban.com/top250?start={start_num}",headers = headers)
    html = response.text
    soup = BeautifulSoup(html,"html.parser")
    all_title = soup.findAll("span",attrs={"class":"title"})
    for title in all_title:
        title_string = title.string
        if "/" not in title_string:
            print(title_string)
相关推荐
寒月小酒10 小时前
第三章 索引构建(2-all -in-rag学习)
学习
天国梦10 小时前
中学生居家英语听力训练深度解析:从核心痛点到AI赋能的全链路方案
人工智能·学习
胡渠洋15 小时前
postman学习
学习·测试工具·postman
Amazing_Cacao16 小时前
CFCA精品可可产区风土解析(美洲):无情打破风味堆叠假象,建立时间轴上的层次动态阅读系统
学习
六点_dn16 小时前
Linux学习笔记-shell运算符
linux·笔记·学习
其实防守也摸鱼17 小时前
渗透--损坏的对象级别鉴权漏洞(Broken Object Level Authorization, BOLA)
大数据·网络·数据库·学习·tcp/ip·安全·安全威胁分析
念雨思17 小时前
信用卡权益对比:基于HarmonyOS + ArkTS的AI智能金融助手开发实践
人工智能·学习·华为·金融·harmonyos·鸿蒙
铅笔侠_小龙虾17 小时前
Rust 学习(2)-变量、常量与 shadowing
学习·算法·rust
it小生010117 小时前
从底层思维到高效行动,顶尖人才进阶核心修炼指南
学习·学习方法
恣逍信点18 小时前
《凌微经》通俗解读——哲学第一因
学习·职场和发展·创业创新·学习方法·业界资讯·交友·哲学