467,920 Members | 1,256 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,920 developers. It's quick & easy.

proxy in urlopen()

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
  • viewed: 6619
Share:
1 Reply
"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.

Similar topics

4 posts views Thread by O. Koch | last post: by
2 posts views Thread by Andre Bocchini | last post: by
1 post views Thread by Herman Geldenhuys | last post: by
2 posts views Thread by Chema | last post: by
1 post views Thread by Alessandro Fachin | last post: by
1 post views Thread by cp.finances.gouv | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.