Mam mały problem i nie wiem kompletnie co jest źle :/
Dla przetestowania zapisałem sobie źródło strony w swoim pliku i próbowałem z wałasnego pliku pobrać to właśnie źródło no ale nic nie idzie i nic nie wywala ...
<?php
$url = 'http://localhost/t4.php';
function getData( $url, $type = 'array' )
{
$data = '';
{
}
{
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_HEADER, false );
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $curl, CURLOPT_FORBID_REUSE, true );
curl_setopt( $curl, CURLOPT_FRESH_CONNECT, true );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_TIMEOUT, 25 );
$data = curl_exec( $curl );
curl_close( $curl );
}
else
{
}
if( ( $type == 'array' ) and
!is_array( $data ) ) {
}
return $data;
}
?>
EDIT
Już działa pobieranie stronki... okazało się że funkcja była wyłączona... dziwne że nie wywalało żadnego błędu... eh.
Teraz jeszcze te cookie.
EDIT
Skrypt już działa. Omija reklamę... poniżej wklejony pobiera i wyświetla podaną przez nas stronkę... może się komuś przyda.
Wielkie podziękowania dla
evolucja!
<?php
$url = 'stronke.któą.pobieramy';
function getData( $url, $type = 'array' )
{
$data = '';
{
}
{
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_HEADER, false );
curl_setopt
( $curl, CURLOPT_COOKIEFILE
, dirname(__FILE__) . '/cookies.txt'); curl_setopt
( $curl, CURLOPT_COOKIEJAR
, dirname(__FILE__) . '/cookies.txt'); curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $curl, CURLOPT_FORBID_REUSE, true );
curl_setopt( $curl, CURLOPT_FRESH_CONNECT, true );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_TIMEOUT, 25 );
$data = curl_exec( $curl );
curl_close( $curl );
}
else
{
}
if( ( $type == 'array' ) and
!is_array( $data ) ) {
}
return $data;
}
?>