By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,986 Members | 1,568 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,986 IT Pros & Developers. It's quick & easy.

proxy in urlopen()

P: n/a
how they define proxy in urlopen? i've tried

a=urlopen('url', proxies=('127.0.0.1:3128'))
a=urlopen('url', proxies='127.0.0.1:3128')

but it says there is an error

==================================
Traceback (most recent call last):
File "getlinks.py", line 3, in ?
a=urlopen('http://forum.octopusnet.lan/',
proxies='127.0.0.1:3128').read()
File "C:\Python23\lib\urllib.py", line 69, in urlopen
opener = FancyURLopener(proxies=proxies)
File "C:\Python23\lib\urllib.py", line 544, in __init__
URLopener.__init__(self, *args, **kwargs)
File "C:\Python23\lib\urllib.py", line 106, in __init__
assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
AssertionError: proxies must be a mapping
Exception exceptions.AttributeError: "FancyURLopener instance has no
attribute 'tempcache'" in <bound method FancyURLopener.__del__ of
<urllib.FancyURLopener instance at 0x00909210>> ignored
==================================
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Egor Bolonev" <eb******@bonbon.net> writes:
AssertionError: proxies must be a mapping
This is telling you proxies must be a mapping type, in this case, a
dictionary. So try replacing:
a=urlopen('url', proxies=('127.0.0.1:3128'))


With this:

a=urlopen('url', proxies={ 'http': '127.0.0.1:3128' })

HTH,

Nick

--
# sigmask || 0.2 || 20030107 || public domain || feed this to a python
print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?')
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.