I'm working with a few pages where javascript executes form submission on page load.
Does the curl library automatically execute javascript in web pages? If it does, is there a way to return the changed DOM instead of the default one that I'm returning with simple curl code.
Here's my currentcode:
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$url);
$buffer = curl_exec_follow($curl_handle,10);
curl_setopt($curl_handle,CURLOPT_HEADER, 0);
curl_setopt($curl_handle,CURLOPT_FOLLOWLOCATION, 1);
$buffer = curl_exec($curl_handle);
No, it does not. It does not apply css styles either.
No. A web page with embedded JavaScript is actually a program. CURL gives you the program's source code (HTML and JavaScript), but doesn't run that program.
To run a page's embedded JavaScript you need (1) a JavaScript interpreter, and (2) the Document Object Model (DOM) for the page.
Browsers have these, but PHP does not.
People are working on PHP versions of these, but developing these are big tasks.
If this is what you need, you might skip PHP and instead look at writing C++ code using WebKit.
PHP curl is NOT a full browser. It is just a library that is used for communicating with servers, using HTTP, FTP, et cetera. It does not do neither rendering nor parsing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With