473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
1 8107
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: O. Koch | last post by:
Until now, i know that ftplib doesn't support proxies and that i have to use urllib2. But i don't know how to use the urllib2 correct. I found some examples, but i don't understand them. Is...
2
by: Andre Bocchini | last post by:
I'm having some trouble using proxy authentication. I can't figure out how to authenticate with a Squid proxy. I know for a fact the proxy is using Basic instead of Digest for the authentication....
1
by: Herman Geldenhuys | last post by:
Hey. Im trying to post some variables to an URL, but I get an error saying that my XML is parsed incorrectly. I know that it is not. At closer inspection I found out that some module in Python...
0
by: Matt | last post by:
I'm trying to get the HTML data off of a webpage. Let's say for the sake of argument it's the python homepage. I've googled around and found some examples that people said worked. Here's what...
1
by: Bloke | last post by:
I want to connect to a https server through an authenticating proxy like this: import urllib2 proxy_info = { 'user' : 'me', 'pass' : 'password', 'host' : 'mycompany.com.au', 'port' : 8008...
2
by: Chema | last post by:
Hi all. I have a little script to connect to the internet and download some files. I developed it in my house (direct connection) and it wordked properly. But the problem is that in the office...
11
by: Phoe6 | last post by:
Hi, The following piece of code works properly when my proxy password contains characters etc. But when my proxy password contained something like '|\/|' , the httplib incorrectly indentified it...
1
by: Alessandro Fachin | last post by:
I write this simply code that should give me the access to private page with htaccess using a proxy, i don't known because it's wrong... import urllib,urllib2 #input url...
1
by: cp.finances.gouv | last post by:
Hello all, I'm facing a strange behavior of urllib2 trying to access gmail account behind a proxy (Squid). The following works perfectly : wget --save-cookies cookies...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.