How can I get whole page contents after that page redirect by javascript?
In executewebpage.php:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setOpt($ch, CURLOPT_POST, TRUE);
$url = 'http://www.doredirect.com';
$postfields = array('doredirect'=>'true','trigger'=>'1');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
echo($data); //In this step, it redirect to page: http://www.finalpage.com
curl_close($ch);
How can I get contents of http://www.finalpage.com?
Note:If I don’t echo, it don’t return anything and don’t redirect to any page
Thank you so much!
Try using this to view the HTML of the curl response:
It’s likely that there is a javascript or meta redirect in there somewhere. Look for this:
or
or
From there, you can build a regular expression (as others have suggested) to find the URL and then fetch it’s contents.