Python autocomplete with a mechanism

Can someone help me or share some code to automatically fill in the login using mechanization ( http://wwwsearch.sourceforge.net/mechanize/ )? I want to make a python script to enter my favorite sites when I run it.

Thank!

+3
source share
2 answers

This will help you log in to one site and load the page, for example:

import mechanize
br=mechanize.Browser()
br.open('http://www.yourfavoritesite.com')
br.select_form(nr=0) #check yoursite forms to match the correct number
br['Username']='Username' #use the proper input type=text name
br['Password']='Password' #use the proper input type=password name
br.submit()
br.retrieve('https://www.yourfavoritesite.com/pagetoretrieve.html','yourfavoritepage.html')

This script assumes your login form is the first page, and your input names are Usernameand Password.
You can also select your form by name:

br.select_form(name="thisthing")

, script .
AlexMartelli, script .

+3

, , ( ), , ( , , "" - !).

, , @systempuntoout, (, , ConfigParser) , script "log_me_in" , , .

" ", , , (, sqlite), , "" .

+1

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


All Articles