简体   繁体   中英

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. 在此处输入图片说明

Is it possible for me to run the "goCourseDetails" js function with my own parameters?

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.

Thanks in advance.

You can use driver.execute_script() to execute javascript snippet in browser.

The function goCourseDetails can be obtain from browser global variable window

driver.execute_script('window.goCourseDetails.call(null, arguments)',
      <department>, <degreelevel>, <course>, <detail>, <year>, <semester>
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM