python - 请求库无法解析代理
问题描述
我无法让我的代理工作。
我在想这与 URL 中的破折号有关。不过我不确定。使用普通代理,例如:110.74.222.71:44970
它可以工作,但是使用这样的代理我得到:
requests.exceptions.InvalidURL:解析失败:http://174.138.162.202:7383:LV16191381-LV1619137936-116: 35fde12g82
import requests
import random
proxy = {
'http' : 'http://174.138.162.202:7383:LV16191381-LV1619137936-116:35fde12g82',
'https' : 'http://174.138.162.202:7383:LV16191381-LV1619137936-116:35fde12g82'
}
headers = {"User Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"}
r = requests.get(url, headers=headers, proxies=proxy)
print(r.status_code)
解决方案
推荐阅读
- javascript - 如何按键对元素进行分组并使用javascript附加该特定键的值?
- airflow - 安排 DAG 每月运行两天
- r - 在 R / Rmd 中使用参数生成 pdf 时拆分标题行
- php - 如何将函数的结果分配给变量?
- php - PHP:数组和键明智
- php - 如何用php格式化csv输出?
- android - 由于信号(SIGALARM)调用,C 本机 android 应用程序在 Oreo 及更高版本上崩溃
- javascript - 将对象绑定到元素的适当位置
- django - 从 ChoiceField/MultipleChoiceField 中的 forms.py 将类传递给标签
- javascript - 如何在 Datatable 中用两列显示多个结果?