×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

execute JS code on page from Python

execute JS code on page from Python

execute JS code on page from Python

(OP)
My job is to get a listing of named features from any web-page using Python. There are some scripts in other languages that do exactly what I need.
When web page is packed I can run the manuscript from JS console (e.g. from dev-tools in GoogleChrome). I have the selection of names of the features as the outcome. Well, however I most likely to the page and perform the manuscript from internet browser manually. However the concern is to do the very same from Python. It can look something like this:

def get_named_functions_list(url):
myscript = settings.get_js_code() # here I get script that I told above

tool.open(url)

while not tool.document.READY: # here I wait while the page will completely loaded
pass

js_result = tool.execute_from_console(myscript)

return list(js_result.values())


def main():
url = "https://wildproofgear.com/"
get_named_functions_list(url)


The result what I want:
1. Request given URL
2. Wait for function document.ready() will finished.
3. Execute javascript on the page (like in browser).
4. Getting of result the JS-code returns.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close