爬虫学习(三)用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)
相关推荐
fanged11 分钟前
设备树学习5--读写实操(TODO)
学习
天天爱吃肉82181 小时前
行业笔记|高压连接器瞬态接触退化通用检测方法论
人工智能·笔记·python·功能测试·学习·汽车
Hhy_11071 小时前
【从零开始学数据结构 ⑥】:二叉树之堆——打破规则的优先队列
c语言·开发语言·数据结构·学习·visual studio
weixin_431600441 小时前
为什么 Agent REPL 要上 Ink:好处、用法与内部设计
前端·学习·ai·agent·ai编程
wangjialelele2 小时前
Spring Cloud 全体系学习笔记(REST、Nacos、Feign、Gateway)
java·spring boot·笔记·学习·spring·spring cloud·gateway
qeen872 小时前
【数据结构】搜索二叉树的介绍与算法原理解析及实现
数据结构·c++·学习·算法·模板
重庆小透明2 小时前
agent开发学习【第一篇】
学习
星辰即远方13 小时前
计算器仿写总结
学习·ui·ios·cocoa·xcode
影寂ldy15 小时前
SQL 事务(Transaction)完整版学习笔记(含转账案例+存储过程+异常捕获)
笔记·sql·学习
Bernice橘子17 小时前
职场英语学习计划Day034
学习