i search for links from a website with this code.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://example.com");
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
// search the results from the starting site
if( $result ){
preg_match_all('/<a href="(http:\/\/www.[^0-9]+.pdf?)"/', $result, $output, PREG_SET_ORDER );
foreach($output as $item ){
print_r($item );
}
}
copy($item, 'file.pdf');
?>
just one pdf links that read. then i need a code to download pdf files that provide by links in php. copy function doesn’t work.
thank you 🙂
i’ve solved it, using this code, thank you for @Oldskool 🙂 :