-1

I need to just load my login page with my credentials entered. I was able to enter the login details and submit using MechanicalSoup My login page says in chrome browser:

Note : Do not close this window, closing this window will log you out.

How can I load the website and hold so, I won't get logged out. For instance,

import mechanicalsoup
browser = mechanicalsoup.StatefulBrowser()

try:
    browser.open("http://172.16.16.16:8090/")  # starting of login site
except:
    print('No connection to Login Page')
    exit()

This will just load my login page(http://172.16.16.16:8090') but will not keep it load. So, login will be disconnected after few time. How can I solve it?

4

1 回答 1

0

在普通的 HTTP/HTML 中,“关闭页面”不会做任何事情,因此如果您正在浏览的网站在您关闭窗口时将您注销,则很可能意味着该网站使用了 javascript(在页面关闭时触发事件) ,beforeunload或定期发送请求以延长会话的持续时间)。如果是这样,那么 MechanicalSoup 将无济于事,因为它不执行 JavaScript。

另请参阅:在 MechanicalSoup (python 3x) 中,如何注销注销按钮为 javascript 的网站MechanicalSoup 的常见问题解答

于 2018-08-20T08:09:14.770 回答