472,958 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

I wanna use urllib2 to get a page with a socks 5 proxy,who can give me a sample code ?

I wanna use urllib2 to get a page with a socks 5 proxy,who can give me
a sample code ?

example,
the proxy server is :123.123.123.123
and the port is :1080
and the username/password is : user/pass
I want to open http://www.google.com

how to write this kind of script?
thanks.

Apr 9 '06 #1
4 7165

Ju Hui wrote:
I wanna use urllib2 to get a page with a socks 5 proxy,who can give me
a sample code ?

example,
the proxy server is :123.123.123.123
and the port is :1080
and the username/password is : user/pass
I want to open http://www.google.com

how to write this kind of script? I'm pretty sure that urllib2 doesn't work with SOCKS proxies of any
kind.

I think you'll have to use pycurl (extension library - not in standard
lib). This is mcuh more powerful, but not so simple to use.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
thanks.


Apr 9 '06 #2
thanks, I will try pycurl.

Apr 10 '06 #3
"Ju Hui" <ph*****@gmail.com> writes:
I wanna use urllib2 to get a page with a socks 5 proxy,who can give me
a sample code ?

[...]

I haven't used it myself (though curiously, ftplib knows about this
module and will use it if present -- and urllib2 uses ftplib to fetch
ftp: URLs), but you could try this

http://www.w3.org/People/Connolly/dr...ForPython.html
And monkeypatch urllib2 (and everything else that uses module socket!)
something like so (UNTESTED):

import sys, os

os.environ['SOCKS_SERVER'] = 'joe:pa******@proxy.example.org'
import SOCKS
from socket import getfqdn
SOCKS.getfqdn = getfqdn
sys.modules['socket'] = SOCKS
del getfqdn, SOCKS

import urllib2
then just use urllib2 normally...

John

Apr 12 '06 #4
thanks a lot!

Apr 13 '06 #5

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...
4
by: bmiras | last post by:
I've got a problem using urllib2 to get a web page. I'm going through a proxy using user/password authentification and i'm trying to get a page asking for a HTTP authentification. And I'm using...
1
by: Ray Slakinski | last post by:
Hello, I have defined a function to set an opener for urllib2, this opener defines any proxy and http authentication that is required. If the proxy has authencation itself and requests an...
1
by: tomazi75-nospam(at)gmail.com | last post by:
Hello all, I've a problem using urllib2 with a proxy which need authentication. I've tested the 'simple way' : -- code -- import urllib # example values for the post
6
by: Alejandro Dubrovsky | last post by:
I see from googling around that this is a popular topic, but I haven't seen anyone saying "ah, yes, that works", so here it goes. How does one connect through a proxy which requires basic...
3
by: itay_k | last post by:
Hi, I am running the following simple code (just open connection to some https page with proxy): proxy= '666.179.227.666:80' proxy=urllib2.ProxyHandler({"https":'https://'+proxy}) opener =...
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...
6
by: Jack | last post by:
I'm trying to use a proxy server with urllib2. So I have managed to get it to work by setting the environment variable: export HTTP_PROXY=127.0.0.1:8081 But I wanted to set it from the code....
1
by: Magnus.Moraberg | last post by:
Hi, I have the following code - import urllib2 from BeautifulSoup import BeautifulSoup proxy_support = urllib2.ProxyHandler({"http":"http:// 999.999.999.999:8080"}) opener =...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.