爬虫学习(三)用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)
相关推荐
传奇开心果编程2 小时前
【Rust入门知识点学与练】第24课:Trait 基础
开发语言·学习·rust
潜心一志7 小时前
HALCON软件——基本架构,算子参数
学习·计算机视觉
爱吃苹果的日记本8 小时前
数据结构第三课(时间复杂度)
数据结构·学习
泡泡鱼(敲代码中)11 小时前
MySQL基础学习笔记:从数据模型到DDL全掌握
开发语言·数据库·笔记·学习·mysql
fanged12 小时前
Agent的Skills(TODO)
学习
是隼人12 小时前
buuctf-pwn picoctf_2018_shellcode(ret2shellcode)题解(学习过程持续更新)
c语言·学习·安全·pwn入门·ctf入门
m4Rk_13 小时前
【论文阅读】Agent 记忆机制(69):STITCH——用上下文意图解决“语义相关但情境错误”的记忆检索
论文阅读·人工智能·学习·开源·github
2601_9499506313 小时前
个人在线刷题的工具
学习·考研·小程序·刷题·小程序推荐
一尘之中13 小时前
深入解析面向服务的架构(SOA):从特性到实施
学习·架构·ai写作
秦哈哈14 小时前
【Hello Agents】学习笔记(二)
笔记·学习·microsoft