简介
代理:使用别人的ip地址发送请求,隐藏自己的ip地址。再requests.get()通过 proxies=proxies实现
需要获取另一个电脑的ip地址和可用端口号。ip地址再百度搜免费代理
url = "https://www.baidu.com" proxies = { "https":"https://113.96.219.105:4015" } headers = { "user-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36" } response = requests.get(url=url,proxies=proxies) response.encoding = "utf-8" print(response.text)