Python, bots, mechanize

0

I'm making a bot that is able to enter my router, go to a certain tab and click the reset button. The idea is simple, I simply intend to restart the router in an automated way, in python.

For this I am using the Python Mechanize library.

import mechanize

br = mechanize.Browser()
br.set_handle_robots(False)
response = br.open("http://192.168.0.1/")

br.select_form(nr=0)
br.form['loginUsername']='XXXXX'
br.form['loginPassword']='XXXXX'
response=br.submit()

if(response.read().find("wifi")) != -1:
    # ????? 

Well, as you can see, I had to use the set_handle_robots method because the router detected that it was not human to connect, and it would not let me access.

Now, I have been able to access the router, through the previous form.

If you find the string 'wifi', it means that it is inside, however, here is when I get lost, because the restart button is in another tab (another page, I imagine that from the same object indicating the new url, is able to follow the redirection without closing the session). However, the button on that tab is a button.

It is not a form. I contribute image:

And honestly, I do not have the slightest idea of running that button.

Thanks in advance.

    
asked by Omar 25.05.2018 в 12:29
source

0 answers