标签:request gen https lis cti xxx int requests sts
通过爬取豆瓣的电影排行榜
import requests url = "https://movie.douban.com/j/chart/top_list" #params是get请求带参数 #data是post请求带参数 #重新进行封装参数 param = { "type":"24", "interval_id":"100:90", "action":"", "start":10, #start作为此网站下拉加载更多的编码 "limit":20, } res = requests.get(url = url, params = param) print(res.request.headers)
这里会输出是是headers里的信息,发现是python,之后加上headers
headers: { "User-Agent":"XXXX" } res1 = requests.get(url = url,headers = headers,params = param) print(res1.text) res1.close() res.close()
爬取完记得要关闭否则过多会出现堵塞
标签:request gen https lis cti xxx int requests sts
原文地址:https://www.cnblogs.com/YuyuFishSmile/p/14919018.html