|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
Python代码如下:
import requests
url = "https://images.google.com.hk/"
proxies = {"http": "http://127.0.0.1:1080"}
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36",
"Connection": "keep-alive",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Language": "zh-CN,zh;q=0.8",
}
response = requests.get(url, proxies=proxies, headers=headers)
response.encoding = 'UTF-8'
with open("cat.txt", "wb") as f:
f.write(response.content)
在跑的时候提示ConnectionError异常:Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
|
|