Changing Selenium Python IP Address

I am writing a web scraper using Selenium for Python. A scraper visits the same sites many times per hour, so I was hoping to find a way to change my IP address every few requests. What is the best strategy for this (I am using firefox)? Is there any pre-written code / csv of IP addresses that I can switch from? I am completely new to disguising IP, proxies, etc., so please don't be shy about me!

+2
source share
2 answers

Try using a proxy. There are free options (not very reliable) or paid services.

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
+1
source

- IP-. - hidemyass.com, , , , -, , .

, -, - -, . , - , , - ​​ - , FTP- ...

0

Source: https://habr.com/ru/post/1016902/


All Articles