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"}}'

 

posted @ 2016-10-08 09:52  lvmememe  阅读(2331)  评论(0编辑  收藏  举报