In MechanicalSoup (python 3x) how to logout a website whose logout button is a javascript

断了今生、忘了曾经 提交于 2019-11-26 14:56:25

问题


I could successfully login and navigate through a website but when I inspected the logout button it is like javascript:__doPostBack('ctl00$lnkBtnLogout','') as link, follow_link() doesn't work on this (saying: no adapters)??? Can someone help me?


回答1:


From https://github.com/MechanicalSoup/MechanicalSoup:

A Python library for automating interaction with websites. MechanicalSoup automatically stores and sends cookies, follows redirects, and can follow links and submit forms. It doesn't do JavaScript.

This gives you two options.

Do the JavaScript yourself

Read the JavaScript. Reverse engineer it. Reimplement it in Python. Figure out what data in the page is dynamic and needed for the algorithm. Extract that using MechanicalSoup and insert it into your reimplementation.

Don't use MechanicalSoup

Use something which does support JavaScript (such as Selenium or PhantomJS) instead.



来源:https://stackoverflow.com/questions/49366610/in-mechanicalsoup-python-3x-how-to-logout-a-website-whose-logout-button-is-a-j

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!