i want to get the source code of this webpage: http://www.pornhub.com/view_video.php?viewkey=5984790cc93d68a4f181 I hv tried like this; <?php $fh = fopen("http://www.pornhub.com/view_video.php?viewkey=5984790cc93d68a4f181", "r") or die("***CANNOT READ***"); $fullstring; while(!feof($fh)) { $output = htmlspecialchars(fgets($fh, 1024)); #echo ("$output"); $fullstring = $fullstring."".$output; } echo $fullstring; ?> PHP: But it says it is not possible to read the file! here the demo of this code: http://getvidz.info/demo.php -> NOT working But , this works fine... when tried using this : http://demo.efoxt.com/4zerandibbuy/ How to do such a thing! ... i just want to read the source; if possible.... pls provide sample code
mate use CURL... here is a little function I wrote for u.. function get_content($url) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)'); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); ob_start(); curl_exec ($ch); curl_close ($ch); $string = ob_get_contents(); ob_end_clean(); return $string; } //usage sample $url = "http://www.pornhub.com/view_video.php?viewkey=5984790cc93d68a4f181"; $mydata = get_content($url); echo $mydata; PHP: btw the code is not tested
I suggest you read the PHP manual, http://www.php.net/manual/en/curl.examples-basic.php Read the comment made by "cmnajs at gmail dot com"