I am using Curl To Log into a website and scrap the data. On this website I need to click a js link then download a file. Using Curl I can login and store the session cookies, but how can I use that information to run some js and download a file. Do I need to run all of the code in an emulator or something to that effort.
1 Answer
As you have already guessed, running JS code requires a JS engine. And because JS code usually interacts with DOM, you also need a DOM context for it. JS engine and a DOM context effectively constructs a headless browser such as Phantom.js. Inside such headless browsers, you can login/click buttons programatically - all JS codes will run normally. However, operating such thing is not a PHP domain anymore.
2 Comments
Alex Pelletier
Thanks for the reply, Phantom.js is exactly the type of thin I was looking for. You said "However, operating such thing is not a PHP domain anymore." by this do you mean it can't (or it won't be easy) to run it along side php?
Kita
Sorry, i was wrong. Googling "php phantom.js" showed me quite a few php bindings like github.com/jonnnnyw/php-phantomjs. You can control phantomjs in php.