0

Is it possible to call a Javascript function on a website that I'm web scraping and saving the result of the function?

I'm using Requests to establish a connection and saving certain pages that I need and BeautifulSoup to make it readable and accessing certain parts.

There is one part that I'm not sure how to call, or even if it's possible:

<tr class=TRDark> <td width=100% colspan=3> <a href="" onclick="OpenPayPlan('payplan.asp?app=******');return false;"> Betalingsplan </a> </td> </tr> 

This function will open a new window and calculate some data that I need. Is this possible to do with Python?

I cannot use Selenium or similar programs for this. This must be executed in the terminal and only the terminal.

5
  • You can use JSOn parseCommentedDec 20, 2017 at 7:43
  • There are no JSON files on the website
    – patski
    CommentedDec 20, 2017 at 7:51
  • 1
    Selenium can use "headless browser" so it can run in terminal.
    – furas
    CommentedDec 20, 2017 at 8:22
  • check in DevTool in Chrome/Firefox maybe this code send data to servet and get result from server - so you could do the same without JavaScript.
    – furas
    CommentedDec 20, 2017 at 8:26
  • what page is this? Maybe it has API and python module so you could do it without all JavaScript.
    – furas
    CommentedDec 20, 2017 at 8:30

1 Answer 1

2

You need to find a JavaScript interpreter with Python bindings maybe. When you've found one which will fit with your needs you can read the documentation and there you can see how this interpreter works. An example could be pyv8. Python however, does not include a JavaScript interpreter.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.