使用Python在远程网站上触发Javascript事件 [英] Trigger Javascript event on remote website with Python
问题描述
我写了一些基本的Python代码来抓取远程网页并抓取一些数据。在我试图抓取的另一个页面上,数据在视图中隐藏,并且仅在更改< select>
框的值后才会显示。
I wrote some basic Python code to scrape a remote webpage and grab a few pieces of data. On a different page I'm trying to scrape, the data is hidden from view, and only appears after changing the value of a <select>
box.
在通过远程网站的javascript进行去除和挖掘之后,我确认它正在使用AJAX(我认为是Prototype的自定义实现)来切换< tbody>
< table>
我对抓取感兴趣。
After de-minifying and digging through the remote website's javascript, I confirmed that it is using AJAX (custom implementation of Prototype I think) to switch the <tbody>
of the <table>
I'm interested in scraping.
有没有办法使用Python(或通过Python的Javascript)来触发该选择框的onChange事件,这样我就可以刷新DOM并获取新的HTML?
Is there a way to use Python (or Javascript via Python) to trigger the onChange event of that select box so I can "refresh" the DOM and grab the new HTML?
推荐答案
找出AJAX请求URL并直接请求它。 : - )
Figure out the AJAX request URL and request it directly. :-)
这篇关于使用Python在远程网站上触发Javascript事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!