我试图使用machanize进入一个网站,但是当我运行我的脚本时,它仍然只是给我主页的来源而不是实际的网站
这是代码
from mechanize import Browser
USERNAME = "my username"
PASSWORD = "my pass"
LOGIN_PAGE = "https://ps.rsd.edu/public/"
browser = Browser()
browser.open( LOGIN_PAGE )
browser.select_form( nr=0 )
browser['pw'] = PASSWORD
response = browser.submit()
print response.read()
请帮忙!
答案 0 :(得分:1)
您忘了输入用户名。它应该输入与密码相同。例如:
from mechanize import Browser
USERNAME = "my username"
PASSWORD = "my pass"
LOGIN_PAGE = "https://ps.rsd.edu/public/"
browser = Browser()
browser.open( LOGIN_PAGE )
browser.select_form( nr=0 )
browser['account'] = USERNAME
browser['pw'] = PASSWORD
response = browser.submit()
print response.read()