My task is to get a list of named functions from any web-page using Python.
I have a script written using JavaScript. It does what I need.
When page is loaded I can run the script from JS console (e.g. from dev-tools in GoogleChrome). I have the array of names of the functions as the result. Well, but I go to the page and execute the script from browser manually. But the question is to do the 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())
So, is there a tool in Python that helps to solve the problem automatically?
UPDATE: To be more clear I can divide the task to the list of subtasks (in Python):
- Request to the given url
- Waiting for document.ready(function...) will finished.
- Execute my JS-code (like in browser).
- Getting of result the JS-code returns.