[英]Run a javascript function of a website using Python
I've been wondering whether or not this is possible - 我一直在想这是否可能-
Here is a picture of Chrome's "inspect element" on this website. 这是此网站上Chrome的“检查元素”的图片。
Is it possible for me to run the "goCourseDetails" js function with my own parameters? 我可以使用自己的参数运行“ goCourseDetails” js函数吗?
I'm using Python and selenium to try and write a script that does that for me, but I don't know how to access the JS function. 我正在使用Python和Selenium尝试编写一个脚本来为我完成任务,但是我不知道如何访问JS函数。
Thanks in advance. 提前致谢。
You can use driver.execute_script()
to execute javascript snippet in browser. 您可以使用
driver.execute_script()
在浏览器中执行javascript代码段。
The function goCourseDetails
can be obtain from browser global variable window
可以从浏览器全局变量
window
获取功能goCourseDetails
driver.execute_script('window.goCourseDetails.call(null, arguments)',
<department>, <degreelevel>, <course>, <detail>, <year>, <semester>
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.