-1

In my Python program, I need to run the hcaptchaCallback function (screenshot), but the function name has a different numbers each time. Can I somehow run this function by specifying only the first part of the name (hcaptchaCallback)?

driver.execute_script('hcaptchaCallback...()')

enter image description here

  • 1
    There is no built in way to really do that. You could do something like https://stackoverflow.com/questions/2226007/fetching-all-javascript-global-variables-in-a-page and do a match with starts with with find() – epascarello Jan 20 '23 at 14:07

1 Answers1

1

There is nothing that lets you really do that. You might be able to pull off looping over the globals and looking for a variable that starts with your string.

window[Object.keys(window).find(k=>k.startsWith("hcaptchaCallback"))]();

that will call it the way you showed, but looking at the function signature, looks like you are going to have to use call()

epascarello
  • 204,599
  • 20
  • 195
  • 236