开发者

check that a script is actually using a proxy from a ip list

I have a list of proxy ip's that I want to use in one of my python scripts, but how do I verify that I am using one of the ip addresses from the list and not my own? I'm us开发者_运维技巧ing mechanize, but any general explanation of how to do this would be helpful.

This is the first time I have worked with proxies, so anything you can tell me will be be really appreciated.

Thanks


Running wireshark / tshark would be one way.

Many proxies run on port 3128, but substitute this for the proxy you're using. Make you request and if you get traffic to the host and port of your configured proxy, it's probably working. If it goes to the host for the website, then it's not.

E.g. First without a proxy:

$ tshark -i eth0 -n -Nn tcp port 3128 or tcp port 80

from mechanize import Browser
br = Browser()
br.open('http://news.bbc.co.uk')
0.000000 mylocalhost -> nol-vip05.cwwtf.bbc.co.uk TCP 51088 > 80 [SYN]
0.003296 nol-vip05.cwwtf.bbc.co.uk -> mylocalhost TCP 80 > 51088 [SYN, ACK]
0.003318 mylocalhost -> nol-vip05.cwwtf.bbc.co.uk TCP 51088 > 80 [ACK]
0.003375 mylocalhost -> nol-vip05.cwwtf.bbc.co.uk HTTP GET / HTTP/1.1

With a proxy:

br.set_proxies({'http':'some.proxy:3128'})
br.open('http://news.bbc.co.uk')
0.000000 mylocalhost -> some.proxy TCP 57556 > 3128 [SYN]
0.011529 some.proxy -> mylocalhost TCP 3128 > 57556 [SYN, ACK]
0.011571 mylocalhost -> some.proxy TCP 57556 > 3128 [ACK]
0.011636 mylocalhost -> some.proxy HTTP GET / HTTP/1.1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜