Python爬虫示例-豆瓣电影TOP250

📁学习日志📆2023-05-01 🤯PH 👀1,205 次浏览
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) # 去除原名

更多文章

计算机视觉:关键点检测、画质提升

1、关键点检测 花名:关键点定位/对齐/keypoint alignment 输入:包含目标的图像,如人脸图像、人体图像、手部图像等 输出:一组预定义的关键点位置(人脸五官,人体关节,手指关节等) 2、算法分类 regression法:直接回归关键点坐标(DeepPose、MTCNN、MobileNet) +模型简单,可导 +计算量小,速度快 +更好的连续性和稳定性 -容易过拟合(CNN) -空间…

📁 机器学习 📆 2023-05-16
计算机视觉:关键点检测、画质提升
回到顶部