16 JSON 爬虫【反序列化】豆瓣
# 没有安装 requests模块 ,需要安装此模块
pip3 install requests
import json
import requests
res=requests.get(
url='https://movie.douban.com/j/search_subjects?type=tv&tag=%E7%83%AD%E9%97%A8&page_limit=50&page_start=0',
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
}
)
data_dict = json.loads(res.text)
for row in data_dict['subjects']:
print(f" {row['title']},评分{row['rate']},网址:{row['url']}")