このエラーが発生します:
Traceback (most recent call last):
File "script.py", line 7, in <module>
proxy = urllib2.ProxyHandler(line)
File "/usr/lib/python2.7/urllib2.py", line 713, in __init__
assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
AssertionError: proxies must be a mapping
次のスクリプトを実行すると:
import urllib2
u=open('urls.txt')
p=open('proxies.txt')
for line in p:
proxy = urllib2.ProxyHandler(line)
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
for url in u:
urllib.urlopen(url).read()
u.close()
p.close()
私のurls.txtファイルにはこれがあります:
'www.google.com'
'www.facebook.com'
'www.reddit.com'
私のproxyes.txtにはこれがあります:
{'https': 'https://94.142.27.4:3128'}
{'http': 'http://118.97.95.174:8080'}
{'http':'http://66.62.236.15:8080'}
hidemyass.comで見つけました
私が行ったグーグルによると、この問題を抱えているほとんどの人は、プロキシのフォーマットが間違っています。これはここにありますか?