requests设置headers,proxies,cookies
header = {'referer':'http://www.baidu.com'} # referer代表从什么网页跳过来的,其他属性同理设置 proxy = { 'http':'115.28.50.142:80', 'https':'115.28.50.142:80', } # 其他IP同理,这里这个IP随便填的 r = requests.get('http://www.123.com', headers = header , proxies = proxy , timeout=5) print(r.text)
>>> url = 'http://httpbin.org/cookies' >>> cookies = dict(cookies_are='working') >>> r = requests.get(url, cookies=cookies) >>> r.text '{"cookies": {"cookies_are": "working"}}'