简体   繁体   中英

change ip address from the available addresses of the network in python

Actually Iam trying to extract data from a site.But it ends with

Maximum tries exceeded Error

I have tried sleep() method also but didnt work.so how to find all the available addresses for my machine.

I found this example in here

net4 = ipaddress.ip_network('192.0.2.0/24')
for x in net4.hosts():
    print(x)  

192.0.2.1
192.0.2.2
192.0.2.3
192.0.2.4 ...

can I use this for changing my ip every 10 seconds ?

I am confused. what is 192.0.2.0/24 here and what am I supposed to give in the place of 192.0.2.0/24 and how can I know my machine's ip address or ip_network so I can give the value in net4 = ipaddress.ip_network('192.0.2.0/24')

If it says Maximum tries exceeded , then the system is doing one of two things:

  1. It's using your session information to track how many times you've tried - in this case, you can just start a new requests.session() to fix this

  2. It's using your external IP address - in this case, changing your internal IP address won't make much of a difference

Either way, changing your internal IP address won't affect the outcome of your script

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