Cookie----在用requests包请求网页服务时需要使用
为什么会写这篇文章,本人晚上喜欢和同学玩CSGO,发现该游戏的饰品可以买卖交易,所以突发奇想想写一个网易buff的脚本,参考https://blog.csdn.net/Tianbibilailai/article/details/136641424
很快遇到第一个问题Cookie怎么查看
class CS():
def __init__(self):
self.nowtime = datetime.now()
self.goodsurl = 'https://buff.163.com/api/market/goods'
self.pricehistoryurl = 'https://buff.163.com/api/market/goods/price_history/buff'
self.my_headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36",
"Cookie": "yourcookie",#你自己的cookie
"Host": "buff.163.com",
"Referer": "https://buff.163.com/market/?game=csgo",
"X-Requested-With": "XMLHttpRequest"
在这段代码中Cookie字段需要自己更改,但是本人是门外汉并不知道,但是在网上找了许久终于找到答案!!!!!!!!!!!!
查看自己Cookie的步骤
第一步:打开谷歌浏览器。(因为代码里模仿的是谷歌浏览访问网易的官网)
第二部:打开网易buff官网并登录。
第三步:右键网页点击检查按钮并选择network选项
第四步:键盘:Ctrl + R重新发送登录信息
第五步:在左边列表点击最上面的网址,在右边列表往下移就可以查看自己Cookie
s/