【发布时间】:2020-02-11 02:57:36
【问题描述】:
我正在尝试从 GitHub 用户内容中读取文本文件(代理列表)。代码将返回一个随机行,但它没有按预期工作。
我的代码:
res = reqs.get('https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list-raw.txt', headers={'User-Agent':'Mozilla/5.0'})
proxies = []
for lines in res.text:
proxies = ''.join(lines)
print proxies
return proxies
这是我得到的:
.
2
1
:
8
0
8
0
1
9
2
.
1
6
2
.
6
2
.
1
9
7
:
5
9
2
4
6
这是预期的:
178.217.106.245:8080
186.192.98.250:8080
如果可以返回随机行那就更好了。
【问题讨论】:
-
更改了标题以跟随内容,改进了帖子的格式,包括代码部分和文本。
标签: python python-2.7 proxy python-requests