requests设置代理ip

# coding=utf-8

import requests

url = "http://test.yeves.cn/test_header.php"

headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
    "referer": "https://www.pexels.com/zh-cn/photo/4k-1484728/"
}

data = {"id": 1, "name": "wang"}
proxy = {
    "http":"http://218.21.230.156:808"
}
response = requests.post(url, headers=headers, data=data,proxies=proxy)
print(response.json()) "referer": "https://www.pexels.com/zh-cn/photo/4k-1484728/"
}

data = {"id": 1, "name": "wang"}
proxy = {
    "http":"http://218.21.230.156:808"
}
response = requests.post(url, headers=headers, data=data,proxies=proxy)
print(response.json())

 

posted @ 2020-03-07 16:32  brady-wang  阅读(2306)  评论(0编辑  收藏  举报