5.02-requests_proxy

import requests

# 1.请求url
url = 'http://www.baidu.com'
headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36'
}

free_proxy = {'http': '27.17.45.90:43411'}

response = requests.get(url=url, headers=headers, proxies=free_proxy)

print(response.status_code)

 

posted @ 2019-03-26 20:51  hank-li  阅读(112)  评论(0编辑  收藏  举报