7

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);
1
  • cURL does not have a JavaScript parser, therefore can not execute it. Commented Feb 6, 2011 at 8:02

3 Answers 3

14

No, it does not. It does not apply css styles either.

Sign up to request clarification or add additional context in comments.

Comments

5

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.

1 Comment

A web page should not be described as a 'program'.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.