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()方法,会使该连接持久化
proxies={
'http': 'http://ip:port',
'https': 'http://ip:port',
}
import requests
url=""
response=requests.get(url=url, proxies=proxies)
import requests
url=""
session = requests.session()
session.proxies.update(proxy)
import httpx
proxies = {
'http://': 'http://ip:port',
'https://': 'http://ip:port',
}
url = ""
response = httpx.get(url=url, proxies=proxies)