Reputation: 61
I am trying to crawl through a page but only loading GIF is retrieved not the page content.
$url = "https://www.truecaller.com";
$request = $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
print_r($data);
curl_close($ch);
any way to retrieve full page.
Upvotes: 2
Views: 940
Reputation: 61
There is a reason for that.
so what's happening is that It gets your response as soon as you hit the page. there is a gif that is being loaded at first it will return you loading gif. then on the base of javascript condition remaining page is loaded. as it fails to execute javascript so the only response you are getting is that loading gif.
If you want to load full page content there is a full webkit browser without an interface that helps programmers to achieve results as a browser gets.PhantomJS - Scriptable Headless Browser.
Upvotes: 2
Reputation: 5310
I see you have already tried adding a delay to your curl, but the fact is curl is not the right tool for this job. I would investigate http://phantomjs.org/ which will allow you to capture the page more robustly.
@hassan added below, this site has an API so that is also an option. Thanks hassan.
Upvotes: 0