python 爬虫笔记 获取网页cookies

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/12/5 8:59
# @Author  : huni
# @File    : 11111111111111111111111.py
# @Software: PyCharm

import requests

headers = {
     
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36'
}
url = 'https://www.xxx.com'

a = requests.get(url,headers=headers)
cookies = a.cookies
for key in cookies.keys():
    print(key + '=' + cookies.get(key))
    'ASPSESSIONIDQWCACDDB=BCJNLHFBDCMJDFNGPFEBPNFO'     # 抓包来的cookies
    'ASPSESSIONIDQWCACDDB=ANJNLHFBLGKEHDLHPGDECDMI'     # 本程序打印的cookies


你可能感兴趣的:(python,url,ruby,chrome,脚本语言)