Oto dwa różne, prostych sposobów, aby uzyskać zawartość z URL:
1) Pierwsza metoda
Włącz allow_url_include z hostingu (PHP.ini albo gdzieś)
<?php
$variableee = readfile("http://example.com/");
echo $variableee;
?>
lub
2) Druga metoda
Włącz php_curl, php_imap i php_openssl
<?php
// you can add anoother curl options too
// see here - http://php.net/manual/en/function.curl-setopt.php
function get_dataa($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$variableee = get_dataa('http://example.com');
echo $variableee;
?>
Czy możesz wyjaśnić to jeszcze bardziej. Chcesz wysłać żądanie sieciowe pod wskazany URL i odczytać odpowiedź na zmienną? –
Tak, tego samego chcę, chcę całego kodu źródłowego w zmiennej zwracanej przez to żądanie WWW. – Prashant
Możesz użyć [tego narzędzia] (http://codecanyon.net/item/javascript-web-scraper/8598806), aby łatwo pozbyć się html. –