简体   繁体   中英

In python with selenium, how do you rotate IP addresses?

I am trying to scrape information off of a website (on Chrome) where I need to click on each subpage to get the information I need. After about 7, I get blocked by the website. I think if I was able to switch IPs either each time or once I get blocked, that would work.

I am using Selenium to open the site and navigate to the subpages. I have tried using a try-catch block so far and a while loop but I am getting errors I do not know how to address.

Does anyone have an alternative approach or previous success doing this?

There is a good chance that the Website you are trying to connect will use the IP address of your ISP, So it's Not easy to fool the Destination website. You can still try to renew the IP address using "IPConfig / renew" OR "IPConfig / renew6".

You can explore and check whether any of the netstat commands can help you the Win 10 commands are given here NetStat Commands for Windows 10 . Additionally, In the past I have tried to interchange between my Mobile connection (teethering) and then router to achieve the same.
Further,
A router restart is (Often) what it takes to Reset your ISP's IP address.

You can use rotating proxies to change your IP per request or with a time interval but If you don't want to use any proxy you can restart your router to get a new IP address from your ISP but If you have a static IP from your ISP even through you restar your router your IP will stay the same.

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