0

I'm using cURL to access a site. The problem is that content that I need to grab is generated by a script as:

function Button(){
...
document.getElementById("out").innerHTML = name;
}

<p id="out"></p>

With cURL, I have the code of the page but not the content. I'm using this config:

  $curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_REFERER, $referer);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookiefile);
$redirects=5000;
$data = curl_redirect_exec($curl,$redirects);
curl_close($curl);

I could get the content generate by the script.

1

1 Answer 1

1

You cannot get data rendered in JS from PHP CURL. What you need is a headless browser, something that runs client side scripts like Phantom.JS or Casper.JS which have the capability of running Client-Side JavaScript.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.