当前位置: 首页>>代码示例>>PHP>>正文


PHP Crawler::readline方法代码示例

本文整理汇总了PHP中Crawler::readline方法的典型用法代码示例。如果您正苦于以下问题:PHP Crawler::readline方法的具体用法?PHP Crawler::readline怎么用?PHP Crawler::readline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crawler的用法示例。


在下文中一共展示了Crawler::readline方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: crawl_1_chapter

function crawl_1_chapter($url, $chapter)
{
    global $sitename;
    global $prefix;
    $c = new Crawler($url);
    $c->go_to('name="pagejump"');
    $pages = array();
    while ($line = $c->readline()) {
        if (Crawler::is_there($line, '<option')) {
            $pages[] = Crawler::extract($line, 'value="', '"');
        } else {
            if (Crawler::is_there($line, '</select>')) {
                break;
            }
        }
    }
    $c->go_to('id="nextpage"');
    $c->readline();
    $img = $c->getbetween('src="', '"');
    $c->close();
    $img_base = dirname($img);
    $ext = '.jpg';
    $chapter = Crawler::pad($chapter, 3);
    foreach ($pages as $page) {
        echo "<a href='{$img_base}/{$page}{$ext}'>{$prefix}-{$chapter}-{$page}{$ext}</a><br/>\n";
        flush();
    }
    //print_r($pages);flush();
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:29,代码来源:mangashare.php

示例2: crawl_one_page

function crawl_one_page($url)
{
    $nims = array();
    $kraw = new Crawler($url);
    $kraw->go2linewhere('------------------------------------------');
    $kraw->go2linewhere('------------------------------------------');
    $kraw->readline();
    while ($kraw->strpos('------------------------------------------') === false) {
        $nims[] = $kraw->getbetween(' ', '  ');
        $kraw->readline();
    }
    $kraw->close();
    return $nims;
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:14,代码来源:akademik.php

示例3: crawl_page

 public function crawl_page($url)
 {
     // crawl_page
     $c = new Crawler($url);
     // get title
     $c->go_to('<title>');
     $title = Crawler::extract($c->curline, 'PHD Comics: ', '</title>');
     $title = preg_replace('/\\W/', '_', $title);
     // get the date
     $c->go_to('date_left.gif');
     $c->readline(2);
     $line = $c->curline;
     preg_match('/([0-9]+)\\/([0-9]+)\\/([0-9]+)/mi', $line, $matches);
     //print_r($matches);flush();
     list($full, $month, $date, $year) = $matches;
     if (strlen($date) < 2) {
         $date = '0' . $date;
     }
     if (strlen($month) < 2) {
         $month = '0' . $month;
     }
     $fileprefix = "{$year}_{$month}_{$date}_{$title}";
     // get the img url
     $c->go2linewhere('<td bgcolor=#FFFFFF');
     $line = $c->curline;
     preg_match('/<img src=["\']?([^ ]+)["\']?/i', $line, $matches);
     $img = $matches[1];
     $filename = basename($img);
     $ext = substr($filename, strrpos($filename, '.'));
     echo "<a href='{$img}'>" . $fileprefix . $ext . "</a><br/>";
     flush();
     $c->close();
     unset($c);
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:34,代码来源:phdcomics.php

示例4: crawl_1_page

function crawl_1_page($url)
{
    echo "URL2 {$url} <br/>\n";
    flush();
    $dirname = html_entity_decode(Crawler::cutfromlast1(substr($url, 0, strlen($url) - 1), '/'));
    $hasil = array();
    $c = new Crawler($url);
    $c->go_to('<div class="entry">');
    while ($line = $c->readline()) {
        if (Crawler::is_there($line, "href='")) {
            $img = Crawler::extract($line, "href='", "'");
            echo "<a href='{$img}'>{$dirname}</a><br/>\n";
            flush();
        } else {
            if (Crawler::is_there($line, 'href="')) {
                $img = Crawler::extract($line, 'href="', '"');
                echo "<a href='{$img}'>{$dirname}</a><br/>\n";
                flush();
            } else {
                if (Crawler::is_there($line, '</div>')) {
                    break;
                }
            }
        }
    }
    $c->close();
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:27,代码来源:reallycuteasians.php

示例5: crawl_album

function crawl_album($url, $alias = false)
{
    $c = new Crawler($url);
    $c->go_to('<noscript>');
    $c->go_to('<noscript>');
    $c->readline();
    $target = '';
    //$c->curline;
    while ($line = $c->readline()) {
        if (Crawler::is_there($line, '</noscript>')) {
            break;
        } else {
            $target .= trim($line);
        }
    }
    $hasil = Crawler::extract_to_array($target, 'src="', '"');
    $c->close();
    /* kalo mo ngambil desc sebagai nama file
    	preg_match_all('/<img src="([^"]+)"><\\/a><p><a [^>]+>([^<]+)<\\/a>/', $target, $match);
    	//file_put_contents('picasaweb.out', print_r($match, true));exit;
    	foreach ($match[1] as $i => $uri) {
    		$info = pathinfo(basename($uri));
    		$ext = $info['extension'];
    		$name = $match[2][$i];
    		$img = str_replace('/s128/', '/', $uri);
    		echo "<a href='$img'>$name.$ext</a><br />\n";
    	}
    	exit;
    	*/
    if ($alias) {
        foreach ($hasil as $img) {
            $img = str_replace('/s128/', '/d/', $img);
            echo "<a href='{$img}'>{$alias}</a><br/>\n";
            flush();
        }
    } else {
        foreach ($hasil as $img) {
            $img = str_replace('/s128/', '/d/', $img);
            $basename = urldecode(basename($img));
            echo "<a href='{$img}'>{$basename}</a><br/>\n";
            flush();
        }
    }
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:44,代码来源:picasaweb.php

示例6: go

 public function go()
 {
     $mark1 = '<a target="_blank" title="Show fullsized image" href=';
     $mark2 = '<a title="Next Image" rel="next" href=';
     $host = 'http://lu.scio.us';
     $finish = false;
     $number = 0;
     $url = $this->url;
     preg_match('/\\/([^\\/]+)\\/page\\/1/', $url, $m);
     $text = $m[1];
     while (!$finish) {
         echo $url . "<br/>\n";
         flush();
         $c = new Crawler($url);
         $c->go_to('id="pid_');
         while ($line = $c->readline()) {
             if (Crawler::is_there($line, 'src="')) {
                 $img = Crawler::extract($line, 'src="', '"');
                 $img = str_replace('thumb_100_', @$_GET['big'] ? '' : 'normal__', $img);
                 $num = Crawler::pad(++$number, 3);
                 $filnm = basename($img);
                 $ext = Crawler::cutafter($filnm, '.');
                 // $text = $num . $ext;
                 // preg_match('/\/(\d+\/\d+)\//', $img, $m);
                 // $text = $m[1];
                 echo "<a href='{$img}'>{$text}</a><br/>\n";
                 flush();
             } else {
                 if (Crawler::is_there($line, '</ul>')) {
                     break;
                 }
             }
         }
         $c->go_to('class="pager"');
         $c->readline();
         if (Crawler::is_there($c->curline, 'Pager_next')) {
             $finish = false;
             $url = $host . Crawler::extract($c->curline, '<a rel="next" href="', '"');
         } else {
             $finish = true;
         }
         $c->close();
     }
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:44,代码来源:spider_luscious.php

示例7: crawl1page

function crawl1page($url)
{
    echo 'Entering ' . $url . '<br/>';
    flush();
    $c = new Crawler($url);
    $c->go2linewhere('<div class="ngg-gallery-thumbnail"');
    $c->readline();
    $sample = $c->getbetween('href="', '"');
    $c->close();
    $dir = dirname($sample);
    if (!$dir) {
        return;
    }
    $folder = substr($dir, strrpos($dir, '/') + 1);
    $dir = dirname($dir) . '/' . rawurlencode($folder) . '/';
    echo 'Dir:' . $dir . '<br/>' . "\n";
    flush();
    $c = new Crawler($dir);
    $c->go2linewhere('<ul>');
    $c->readline();
    while ($line = $c->readline()) {
        //echo $line;flush();
        if (strpos($line, '</ul>') !== false) {
            break;
        } else {
            if (strpos($line, '"thumbs/"')) {
                break;
            }
        }
        $filename = Crawler::extract($line, 'href="', '"');
        echo '<a href="' . $dir . $filename . '">' . rawurldecode($filename) . '</a><br/>' . "\n";
        flush();
    }
    $c->close();
    echo '<br/>' . "\n";
    flush();
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:37,代码来源:xgallery1.php

示例8: go

 public function go()
 {
     $start_url = $this->url;
     if (preg_match('/gallery1\\.hentaifromhell\\.net/', $start_url)) {
         $base_url = 'http://gallery1.hentaifromhell.net';
     } else {
         $base_url = 'http://gallery.hentaifromhell.net';
     }
     $finish = false;
     while (!$finish) {
         $finish = true;
         echo $start_url, "<br />\n";
         flush();
         $c = new Crawler($start_url);
         $c->go2linewhere('<li class="thumbnail">');
         while ($line = $c->readline()) {
             //echo "<pre>$line</pre><br/>\n";flush();
             if (strpos($line, 'src="') !== false) {
                 //ambil gambar
                 $uri = Crawler::extract($line, 'src="', '"');
                 $uri = str_replace('/thumbs/', '/images/', $uri);
                 preg_match('/(\\/small\\/\\d+-)/', $uri, $matches);
                 $uri = str_replace($matches[1], '/', $uri);
                 //$uri = html_entity_decode($uri);
                 //$this->extract_page($uri);
                 $file = basename(dirname($uri));
                 echo "<a href='{$uri}'>{$file}</a><br/>\n";
                 flush();
             } else {
                 if (strpos($line, 'class="pagNext"') !== false) {
                     //next page
                     $finish = false;
                     $start_url = html_entity_decode(Crawler::extract($line, 'class="pagNext" href="', '"'));
                     break;
                 } else {
                     if (strpos($line, '</table>') !== false) {
                         // selesai
                         break;
                     }
                 }
             }
         }
         $c->close();
     }
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:45,代码来源:spider_hfhgallery2.php

示例9: crawl_1_chapter

function crawl_1_chapter($url, $chapter)
{
    global $sitename;
    global $prefix;
    // http://ani-haven.net/hr-alpha/Psyren/145/
    // @todo
    $chapter = Crawler::pad($chapter, 3);
    $c = new Crawler($url);
    $c->go_to('id="myselectbox3"');
    $c->readline();
    $pages = Crawler::extract_to_array($c->curline, 'value="', '"');
    $c->close();
    // append $url ke $pages
    foreach ($pages as $i => $page) {
        $pages[$i] = $url . $page;
    }
    Crawler::multiProcess(4, $pages, 'crawl_1_page', array($chapter));
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:18,代码来源:havenreader.php

示例10: get_images

 public function get_images($chapter_url, $prefix, $infix)
 {
     $sitename = $this->sitename($chapter_url);
     $c = new Crawler($chapter_url);
     $c->go_to('id="pageMenu"');
     $pages = array();
     while ($line = $c->readline()) {
         if (Crawler::is_there($line, '<option')) {
             $pages[] = $sitename . Crawler::extract($line, 'value="', '"');
         } else {
             if (Crawler::is_there($line, '</select>')) {
                 break;
             }
         }
     }
     $c->close();
     $result = array();
     foreach ($pages as $page) {
         $result = $result + $this->mangareader_1_page($page, $page, $prefix, $infix);
     }
     return $result;
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:22,代码来源:Mangareader_Crawler.php

示例11: foolreader_1_chapter

function foolreader_1_chapter($url, $chapter)
{
    global $sitename;
    global $prefix;
    $chapter = Crawler::pad($chapter, 3);
    $c = new Crawler($url);
    $c->go_to('imageArray = new Array');
    while ($line = $c->readline()) {
        if (Crawler::is_there($line, 'imageArray[')) {
            $img = Crawler::extract($line, "'", "'");
            if (strpos($img, 'http://') !== 0) {
                $img = $sitename . $img;
            }
            $fname = basename($img);
            echo "<a href='{$img}'>{$prefix}-{$chapter}-{$fname}</a><br/>\n";
        } else {
            if (Crawler::is_there($line, 'function loadImage')) {
                break;
            }
        }
    }
    $c->close();
    /*
    // @TODO
    $pages = array();
    while ($line = $c->readline()) {
    	if (Crawler::is_there($line, '<option')) {
    		$pages[] = $sitename . Crawler::extract($line, 'value=\'', "'");
    	} else if (Crawler::is_there($line, '</select>')) {
    		break;
    	}
    }
    //$pages = Crawler::extract_to_array($c->curline, 'value="', '"');
    $c->close();
    
    //Crawler::multiProcess(4, $pages, 'foolreader_1_page', array($chapter));
    */
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:38,代码来源:foolreader.php

示例12: crawl_chapter

 public function crawl_chapter($v)
 {
     $c = new Crawler($v['url']);
     $c->go_to('id="pageMenu"');
     $pages = array();
     while ($line = $c->readline()) {
         if (Crawler::is_there($line, '<option')) {
             $pages[] = $this->sitename . Crawler::extract($line, 'value="', '"');
         } else {
             if (Crawler::is_there($line, '</select>')) {
                 break;
             }
         }
     }
     // $pages = Crawler::extract_to_array($c->curline, 'value="', '"');
     $c->close();
     echo '<ul>';
     // Crawler::multiProcess(4, $pages, array($this, 'mangareader_1_page'), array($v['infix']));
     foreach ($pages as $page) {
         $this->mangareader_1_page($page, $page, $v['infix']);
     }
     echo '</ul>';
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:23,代码来源:mangareader.php

示例13: go

 public function go()
 {
     $start_url = $this->url;
     if (preg_match('/gallery1\\.hentaifromhell\\.net/', $start_url)) {
         $base = 'http://gallery1.hentaifromhell.net';
     } else {
         $base = 'http://gallery.hentaifromhell.net';
     }
     $selesai = false;
     while (!$selesai) {
         echo "{$start_url}<br/>\n";
         $craw = new Crawler($start_url);
         $craw->go2linewhere('showimg.php?c=');
         while ($line = $craw->readline()) {
             if (strpos($line, 'showimg.php?c=') !== false) {
                 $raw = Crawler::extract_to_array($line, '<a href="', '"');
                 foreach ($raw as $r) {
                     $href = str_replace('showimg.php?c=', '', $r);
                     $text = basename(dirname($href));
                     // basename($href);
                     echo '<a href="' . $href . '">' . $text . '</a>' . "<br />\n";
                 }
                 // $href = Crawler::extract($line, '<a href="', '"');
             } else {
                 if (strpos($line, 'Next&raquo;') !== false) {
                     if (strpos($line, '<a href') !== false) {
                         $start_url = $base . Crawler::extract($line, '<a href="', '"');
                     } else {
                         $selesai = true;
                     }
                     break;
                 }
             }
         }
         $craw->close();
     }
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:37,代码来源:spider_hfhgallery1.php

示例14: download_all

 private function download_all($base, $destination)
 {
     $sitename = "http://www.imagefap.com";
     $finish = false;
     $firstbase = $base;
     $i = 1;
     while (!$finish) {
         $c = new Crawler($base);
         echo $base . "\n";
         $c->go_to(array('<table style=', ':: next ::'));
         if (Crawler::is_there($c->curline, ':: next ::')) {
             $finish = false;
             $urld = Crawler::extract($c->curline, 'href="', '"');
             $base = $firstbase . html_entity_decode($urld);
             $c->go_to('<table style=');
         } else {
             $finish = true;
         }
         while ($line = $c->readline()) {
             if (Crawler::is_there($line, 'border=0')) {
                 $img = Crawler::extract($line, 'src="', '"');
                 $img = str_replace('/thumb/', '/full/', $img);
                 $img = preg_replace('/\\/x\\d\\./', '/', $img);
                 $filename = basename($img);
                 $ext = Crawler::cutfromlast($filename, '.');
                 $text = Crawler::n($i++, 4);
                 $this->save_to($img, "{$destination}/{$text}{$ext}");
             } else {
                 if (Crawler::is_there($line, '</form>')) {
                     break;
                 }
             }
         }
         $c->close();
     }
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:36,代码来源:Imagefap_Downloader.php

示例15: Crawler

require_once "crawler.php";
$start_date = '2009-03-10';
$base_url = 'http://www.dilbert.com';
$middle_url = '/strips/comic/';
extract($_GET);
$selesai = false;
$url = $base_url . $middle_url . $start_date;
while (!$selesai) {
    $ada_next = false;
    $c = new Crawler($url);
    echo "URL is {$url}<br />\n";
    flush();
    $c->go2lineor(array('STR_Content', 'STR_Prev'));
    //echo "go2lineor selesai\n";flush();
    if ($c->strpos('STR_Prev') !== false) {
        //masih ada next
        $ada_next = true;
        $url = $base_url . $c->getbetween('<a href="', '"');
        $c->go2linewhere('STR_Content');
    } else {
        $ada_next = false;
        $selesai = true;
    }
    $c->readline();
    $img = $c->getbetween('<img src="', '"');
    echo "<a href='{$base_url}{$img}'>{$start_date}</a><br />\n";
    $start_date = Crawler::extract($url, 'comic/', '/');
    $c->close();
    echo "Closed\n";
    flush();
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:31,代码来源:dilbert.php


注:本文中的Crawler::readline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。