简体   繁体   中英

How to open a link with different proxy IP adresses in python?

I want to click a link over and over again while different proxies are enabled to trick the host into thinking I am doing it on different IP adresses. What is the simples way to do this in python?

Thanks!

First, get a list of proxies, then use something like

import socks
import socket
import urllib2

proxies = ['127.0.0.1:1080', 'someproxy:1888', ... ] # you could load a file here


for proxy in proxies:
    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, *proxy.split(':', 1))
    socket.socket = socks.socksocket
    urllib2.urlopen(URL)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM