예제 #1
0
 $craw = new Crawler($start_url);
 //first get the pictures
 $craw->go2linewhere('class="photogallery-celeb"');
 $craw->readline();
 $line = $craw->curline;
 //echo $line;
 //echo '<br />HOI<br />';
 $ledakan = explode('<img src="', $line);
 for ($i = 1; $i < count($ledakan); $i++) {
     $imgurl = str_replace('/t/', '/', Crawler::cutuntil($ledakan[$i], '"'));
     $file = basename($imgurl);
     echo "<a href='{$imgurl}'>{$file}</a><br />\n";
 }
 //then check the next link
 $craw->go_to('class="arrow">&#187;</a>');
 $url = $craw->getbetweenlast('<a href="', '"');
 if ($url == '#') {
     $masih = false;
 } else {
     $start_url = dirname($start_url . 'a') . '/' . $url;
 }
 /*
 $craw->go2lineor(array('<span class="global_pref_next_no_link">&#187;', 'class="global_pref_next">&#187;'));
 if (strpos($craw->curline, '<span class="global_pref_next_no_link">&#187;') !== false) {
 	$masih = false;
 } else {
 	$start_url = dirname($start_url.'a').'/'.$craw->getbetweenlast('<a href="', '"');
 }
 */
 $craw->close();
 unset($craw);
예제 #2
0
        if ($c->strpos('nodeTitle') !== false) {
            $href = $c->getbetween('<a href="', '"');
            $c2 = new Crawler($base . $href);
            $c2->go2linewhere('pageTitle');
            $title = $c2->getbetween('>', '<');
            $c2->go2linewhere('node_images');
            $ledak = explode('<a href="', $c2->curline);
            for ($i = 1; $i < count($ledak); $i++) {
                $ahref = substr($ledak[$i], 0, strpos($ledak[$i], '"'));
                echo "<a href='{$ahref}'>{$title}</a><br />\n";
            }
            //echo $c2->curline;
            $c2->close();
        } else {
            if ($c->strpos('Go to next page') !== false) {
                echo "\nADA NEXT\n";
                $url = $base . $c->getbetweenlast('</span><a href="', '"');
                break;
            } else {
                if ($c->strpos('Go to previous page') !== false) {
                    echo "\nADA PREVIOUS TANPA NEXT\n";
                    $berhenti = true;
                    break;
                }
            }
        }
    }
    $c->close();
    unset($c);
    flush();
}