Python IP changing
python, selenium
Solution
i recently wrote this script in python 2.7 for linux that should work perfectly for you:
#!/usr/bin/env python
import requests
from os import system
proxies = {'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'}
for x in range(100):
session = requests.session()
session.proxies = proxies
print session.get("http://httpbin.org/ip").text
system("sudo service tor reload") #sudo apt-get install tor
to implement this in selenium (I didn't test this code!):
from selenium import webdriver
def change_proxy(proxy,port):
profile = webdriver.FirefoxProfile();
profile.set_preference("network.proxy.type", 1);
profile.set_preference("network.proxy.http", proxy);
profile.set_preference("network.proxy.http_port", port);
profile.set_preference("network.proxy.ssl", proxy);
profile.set_preference("network.proxy.ssl_port", port);
driver = webdriver.Firefox(profile);
return driver
Problem
First of all i have seen the following post: Selenium Python Changing IP but it didn't help me that much. So i'm currently doing a test website and im trying to make an antibrute force script, my goal is to block the ip after 5 bad tries and to lock the account if 100 different ip's are ban trying password on the account, that would make bruteforce very hard (the only problem would be the fact you could prevent an user from logging in). My problem is that i dont have a clue on how to change ip and how to find 100 different ip's (the selenium article helped me a bit understanding how to change ip). My need would be to either have a script working with the browser and using a website to change ip, or an add-on, or making API calls and doing everything from the command prompt and having that prompt sending request from a proxy service/vpn (by this i mean having my whole traffic under a proxy not just the browser). I have thought of using tor to get new ips everytime