socks

Using urllib2 with SOCKS proxy

我的梦境 提交于 2019-11-27 07:53:25
Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers. So there is SocksiPy library, which works great, but it has to be used this way: import socks import socket socket.socket = socks.socksocket import urllib2 socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "x.x.x.x", y) That is, it sets the same proxy for ALL urllib2 requests. How can I have different proxies for different openers? Try with pycurl : import pycurl c1 = pycurl.Curl() c1

How to use Socks 5 proxy with Apache HTTP Client 4?

大憨熊 提交于 2019-11-27 05:29:28
问题 I'm trying to create app that sends HTTP requests via Apache HC 4 via SOCKS5 proxy. I can not use app-global proxy, because app is multi-threaded (I need different proxy for each HttpClient instance). I've found no examples of SOCKS5 usage with HC4. How can I use it? 回答1: SOCK is a TCP/IP level proxy protocol, not HTTP. It is not supported by HttpClient out of the box. One can customize HttpClient to establish connections via a SOCKS proxy by using a custom connection socket factory EDIT:

General SOCKS server failure when switching identity using stem

守給你的承諾、 提交于 2019-11-27 03:39:51
问题 I have Tor running on a remote server (Ubuntu) on port 9150 with the control port on 9151. I've confirmed both are running via netstat -ant. Here is my code which is eliciting the SOCKS5Error: 0x01: General SOCKS server failure error. import socks import socket socks.set_default_proxy(socks.SOCKS5, server_ip, 9150) socket.socket = socks.socksocket I can make requests from any library and successfully get responses back with a tor ip address. However the following is what causes the error:

How to use URLConnection Timeout

拜拜、爱过 提交于 2019-11-27 03:36:01
问题 I am trying to sort through a list of SOCKS proxies, and figure out which ones have a connect and read time of less than 1000ms, here is my code for(Proxy p : proxies) { try { URLConnection testConnection = testUrl.openConnection(p); testConnection.setConnectTimeout(TIMEOUT_VALUE); testConnection.setReadTimeout(TIMEOUT_VALUE); success.add(p); } catch(SocketTimeoutException ste) { System.out.println("Proxy " + p.address().toString() + " timed out."); } } But every single one of them passes the

Python urllib over TOR? [duplicate]

爷,独闯天下 提交于 2019-11-27 00:42:48
This question already has an answer here: How to route urllib requests through the TOR network? [duplicate] 3 answers Sample code: #!/usr/bin/python import socks import socket import urllib2 socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, "127.0.0.1", 9050, True) socket.socket = socks.socksocket print urllib2.urlopen("http://almien.co.uk/m/tools/net/ip/").read() TOR is running a SOCKS proxy on port 9050 (its default). The request goes through TOR, surfacing at an IP address other than my own. However, TOR console gives the warning: "Feb 28 22:44:26.233 [warn] Your application (using socks4 to

How to make python Requests work via socks proxy

為{幸葍}努か 提交于 2019-11-26 21:26:58
I'm using the great Requests library in my Python script: import requests r = requests.get("some-site.com") print r.text I would like to use socks proxy. But Requests only supports HTTP proxy now. How can I do that? The modern way: pip install -U requests[socks] then import requests resp = requests.get('http://go.to', proxies=dict(http='socks5://user:pass@host:port', https='socks5://user:pass@host:port')) Jim As of requests version 2.10.0 , released on 2016-04-29, requests supports SOCKS. It requires PySocks , which can be installed with pip install pysocks . Example usage: import requests

Using urllib2 with SOCKS proxy

寵の児 提交于 2019-11-26 17:42:53
问题 Is it possible to fetch pages with urllib2 through a SOCKS proxy on a one socks server per opener basic? I've seen the solution using setdefaultproxy method, but I need to have different socks in different openers. So there is SocksiPy library, which works great, but it has to be used this way: import socks import socket socket.socket = socks.socksocket import urllib2 socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "x.x.x.x", y) That is, it sets the same proxy for ALL urllib2 requests. How can

Python urllib over TOR? [duplicate]

泪湿孤枕 提交于 2019-11-26 09:26:26
问题 This question already has answers here : How to route urllib requests through the TOR network? [duplicate] (3 answers) Closed 3 years ago . Sample code: #!/usr/bin/python import socks import socket import urllib2 socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, \"127.0.0.1\", 9050, True) socket.socket = socks.socksocket print urllib2.urlopen(\"http://almien.co.uk/m/tools/net/ip/\").read() TOR is running a SOCKS proxy on port 9050 (its default). The request goes through TOR, surfacing at an IP

How can I use a SOCKS 4/5 proxy with urllib2?

北战南征 提交于 2019-11-26 01:57:47
问题 How can I use a SOCKS 4/5 proxy with urllib2 to download a web page? 回答1: You can use SocksiPy module. Simply copy the file "socks.py" to your Python's lib/site-packages directory, and you're ready to go. You must use socks before urllib2. (Try it pip install PySocks ) For example: import socks import socket socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 8080) socket.socket = socks.socksocket import urllib2 print urllib2.urlopen('http://www.google.com').read() You can also try