MechanicalSoup(python 3x)可以处理网站中的javascript吗? [英] Can MechanicalSoup (python 3x) deal with javascript in a website?
问题描述
我可以成功登录并浏览网站,但是当我检查注销按钮时,它像 javascript:__ doPostBack('ctl00 $ lnkBtnLogout','')
作为链接, follow_link()
对此无效(说:没有适配器)???有人可以帮我吗?
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?
推荐答案
来自 https://github.com/MechanicalSoup/MechanicalSoup :
用于自动与网站进行交互的Python库.MechanicalSoup自动存储和发送Cookie,遵循重定向,并可以遵循链接和提交表单.它不支持JavaScript.
这给您两个选择.
阅读JavaScript.对其进行反向工程.在Python中重新实现它.找出页面中哪些数据是动态的,并且算法需要这些数据.使用MechanicalSoup将其提取,然后将其插入您的重新实现中.
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.
使用支持JavaScript的内容(例如Selenium或PhantomJS)代替.
Use something which does support JavaScript (such as Selenium or PhantomJS) instead.
这篇关于MechanicalSoup(python 3x)可以处理网站中的javascript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!