开发者

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

开发者 https://www.devze.com 2022-12-19 12:28 出处:网络
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 mechaniz

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

精彩评论

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

关注公众号