python requests使用登陆之后的cookie
2023-09-14 09:06:38 时间
def getcontent(self): cookie_text=r'ur=FTW; mid=WsrlLwAEAAEfpCstNyTJl-1oZa0w; ig_pr=1; ig_vh=949; csrftoken=aaaaaaa;ig_vw=186'#字符串格式 cookies = {} for cookie_unit_text in cookie_text.split('; '): cookie_unit = cookie_unit_text.split('=') if len(cookie_unit) >= 2: cookies[cookie_unit[0]] = cookie_unit[1] req=requests.session() req.proxies.update(self.proxies) for k,v in cookies.items(): req.cookies.set(k, v) # 转换cookies param1 = quote_plus(r'33ba35852cb50da46f5b5e889df7d159') param2=quote_plus(r'{"shortcode":"BhRQ25qHnNI","first":1220}') geturl=r"https://www.instagram.com/graphql/query/?query_hash={}&variables={}".format(param1,param2) print(geturl) reqs= req.get(geturl,headers=self.headers) jsonstr=reqs.json() pprint.pprint(jsonstr)
相关文章
- python-使用字典推导式把cookie从字符串转换成字典
- [Python] Working with file
- python分片下载文件
- python-使用字典推导式把cookie从字符串转换成字典
- Python Django Cookie的设置和获取相关属性
- 从零开始学python | 什么是Python JSON?
- 【华为机试真题 Python实现】字符串出现次数最多的字符及次数
- Python爬虫:browsercookie库获取浏览器cookie
- Python爬虫:scrapy查看Cookie值
- Python爬虫:scrapy管理服务器返回的cookie
- Python练习---turtle绘图之绘制天安门
- Python爬虫登录后cookie处理
- selenium python 自定义类调用,同一级目录和跨目录
- selenium + python 字符报错
- macOS chrome selenium python 全屏