mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-01 03:24:43 +00:00
Search CGI formname for login.
This commit is contained in:
parent
a74f8371e6
commit
8e7d7a23c2
1 changed files with 16 additions and 1 deletions
|
|
@ -82,7 +82,7 @@ def submit_login_form (config, url, tc):
|
|||
user, password = config.get_user_password(url)
|
||||
cgiuser = config["loginuserfield"]
|
||||
cgipassword = config["loginpasswordfield"]
|
||||
formname = ""
|
||||
formname = search_formname((cgiuser, cgipassword), tc)
|
||||
tc.formvalue(formname, cgiuser, user)
|
||||
tc.formvalue(formname, cgipassword, password)
|
||||
for key, value in config["loginextrafields"].items():
|
||||
|
|
@ -90,6 +90,21 @@ def submit_login_form (config, url, tc):
|
|||
tc.submit()
|
||||
|
||||
|
||||
def search_formname (fieldnames, tc):
|
||||
"""Search form that has all given CGI fieldnames."""
|
||||
browser = tc.get_browser()
|
||||
for form in browser.get_all_forms():
|
||||
for name in fieldnames:
|
||||
try:
|
||||
browser.get_form_field(form, name)
|
||||
except tc.TwillException:
|
||||
break
|
||||
else:
|
||||
return form.name or form.attrs.get('id')
|
||||
# none found
|
||||
return None
|
||||
|
||||
|
||||
def store_cookies (cookiejar, cookiecache, url):
|
||||
"""Store cookies in cookiejar into the cookiecache."""
|
||||
cookielst = []
|
||||
|
|
|
|||
Loading…
Reference in a new issue