user2207686
user2207686

Reputation: 107

Run JS on web page from Python

I have a script written in python that open a web page in chrome, does some pre-processing on that page and than I need to run a java script code on that web page(manually it can be done using press F12 in chrome and copy to the console), but is there any library that can automate this for me? I mean some command in Python that will run the JS code directly on the opened chrome page(after all the pre-process done on it)?

Upvotes: 0

Views: 368

Answers (1)

Anis R.
Anis R.

Reputation: 6922

Not sure exactly what library/package you are using, but this can be achieved using Selenium, specifically the execute_script function.

This approach is discussed in more detail in this SO question.

Upvotes: 1

Related Questions