Friday, 15 June 2012

python - requests via a SOCKs proxy -



python - requests via a SOCKs proxy -

how can create http request via socks proxy (simply using ssh -d proxy)? i've tried using requests sock proxies doesn't appear work (i saw pull request). example:

proxies = { "http": "socks5://localhost:9999/" } r = requests.post( endpoint, data=request, proxies=proxies )

it'd convenient maintain using requests library, can switch urllib2 if known work.

socks back upwards requests still pending. if want, can view github repository here see branch of socksipy library. branch beingness integrated requests; time before requests supports it, though.

https://github.com/anorov/pysocks/

it should work okay urllib2. import sockshandler in file, , follow illustration within of it. you'll want create opener this:

opener = urllib2.build_opener(socksipyhandler(socks.proxy_type_socks5, "localhost", 9050))

then can utilize opener.open(url) , should tunnel through proxy.

python python-requests

No comments:

Post a Comment