Joseph
Joseph

Reputation: 74

Get Content after the remote URL load successfully

I am using this function for getting contents from Remote URL

function get_contents($purl)
{
$ch = curl_init($purl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
$page = $curl_scraped_page;
return $page;
}

It get content nicely but the one which uses Javascript to load. It remains same like

<div id="content"></div>

I want the inside content also.

I want a function which get content after loading of all js.

Upvotes: 1

Views: 840

Answers (2)

Atul Mishra
Atul Mishra

Reputation: 298

If the content in in html element is filled by ajax, you will need to intercept the ajax response or you will need to identify the javascript method that populates the content in html.

Upvotes: 1

Timo
Timo

Reputation: 106

This is not possible with plane cURL/PHP out of the box. Because cURL will read the plane source code only.

You can use a tool like PhantomJS.

Upvotes: 0

Related Questions