response = requests.get(url=url, headers=headers)
response.cookies.items()
session = requests.session()
response.cookies.items()
response = requests.get(url=url, headers=headers)
set_cookies = response.headers.get('Set-Cookie')
# 注意,如果是重定向的话,会获取不到set-cookie,需要allow_redirects=False来禁止重定向
response = requests.get(url=url, headers=headers, allow_redirects=False)
3.1 将cookie放在cookies参数里
看请求是否发生了302重定向
使用requests.Session()方法,会使该连接持久化
import requests
proxies={
'http': 'http://ip:port',
'https': 'http://ip:port',
}
url=""
response=requests.get(url=url, proxies=proxies)
import httpx
proxies = {
'http://': 'http://ip:port',
'https://': 'http://ip:port',
}
url = ""
response = httpx.get(url=url, proxies=proxies)