Jump to content
dsp77

PHP extractor de link-uri din trafic.ro

Recommended Posts

Salutare,

Am nevoie de cat mai multe site-uri romanesti si m-am decis sa le extrag din trafic.ro cu urmatorul script PHP facut la repezeala si il postez in cazul in care cuiva ii poate fi folositor.

<?php
include('simple_html_dom.php'); // http://simplehtmldom.sourceforge.net/
set_time_limit(0);

$start = 1;
$end = 501;

for($i = $start ; $i < $end ; $i++){
$link[] = 'http://www.trafic.ro/vizitatori/luna-pg'.$i;
}

$html= str_get_html($str);
foreach($link as $v){
$html = file_get_html($v);
foreach($html->find('.ext-url') as $element){
$links[] = $element->innertext;
// echo $element->innertext."\r\n";
}
$html->clear();
unset($html);
// sleep(2);
}
print_r($links);
?>

P.S. Am observat ca trafic.ro mai arunca eroarea HTTP 500 pe care nu o tratez dar se poate relua de la pagina cu pricina schimband $start.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...