Python爬虫示例-豆瓣电影TOP250

📁学习日志📆2023-05-01 🤯PH 👀1,595 次浏览
Python爬虫示例-豆瓣电影TOP250-BtoAI 波特埃

1、requests库

pip install requests

Successfully installed certifi-2022.12.7 charset-normalizer-3.1.0 idna-3.4 requests-2.29.0 urllib3-1.26.15

2、伪装浏览器

import requests
#伪装浏览器
headers = {
"User-Agent":"Mozilla/5.0 (Linux; Andro...."
}
response = requests.get("https://movie.douban.com/top250", headers = headers )
print(response.text)

3.pip install bs4库

Successfully installed beautifulsoup4-4.12.2 bs4-0.0.1 soupsieve-2.4.1

import requests
from bs4 import BeautifulSoup
#伪装浏览器
headers = {
"User-Agent":"Mozilla/5.0 (Linux; Andro..."
}

#自动翻页
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) # 去除原名

更多文章

反向传播(Backpropagation)算法

反向传播算法是一种用于训练神经网络的算法,其作用是根据网络的输出和期望输出之间的误差,来更新网络中的权重和偏置,从而提高网络的性能。

📁 机器学习 📆 2023-10-06
反向传播(Backpropagation)算法

大模型学习路线

整理了一下大模型与多模态大模型的技术路线,包括基础课程、经典教材、开源项目等。 1.什么是大模型 大模型全称是大型语言模型(Large Language Model, LLM),指具有超大规模参数量(通常超过十亿个)的深度神经网络模型。 大模型是自然语言处理(NLP)领域的重要技术分支,从技术角度来看,大模型特指近年来以Transformer架构(谷歌2017年首次提出)为核心的超大规模神经网络模…

📁 机器学习 资料库 📆 2025-06-06
大模型学习路线
回到顶部