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


PHP Crawler::n方法代码示例

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


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

示例1: 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

示例2: str_replace

$sitename = "http://eatmanga.com";
$pref = $_POST['base'];
if (!Crawler::is_there($pref, '/index.php/')) {
    $pref = str_replace($sitename . '/Manga', $sitename . '/index.php/Manga', $pref);
}
if ($base) {
    $finish = false;
    $page = 1;
    while (!$finish) {
        echo "{$base}<br/>\n";
        flush();
        $c = new Crawler($base);
        $c->go2linewhere('mangaviewer_toppest_navig');
        if (Crawler::is_there($c->curline, '&nbsp;&nbsp;&rsaquo;')) {
            $finish = false;
            $base = $pref . '/?page=' . ++$page;
        } else {
            $finish = true;
        }
        $ledak = explode('<img src="', $c->curline);
        $c->close();
        for ($i = 1; $i < count($ledak); ++$i) {
            $segm = $ledak[$i];
            $parturl = Crawler::cutuntil($segm, '"');
            $parturl = str_replace('index.php', 'mangas', $parturl);
            $parturl = str_replace('?action=thumb', '', $parturl);
            echo '<a href="' . $sitename . $parturl . '">' . $prefix . '-' . Crawler::n($chapter, 3) . '-' . basename($parturl) . '</a><br/>' . "\n";
            flush();
        }
    }
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:31,代码来源:eatmanga.php

示例3: crawl_1_page

function crawl_1_page($start_url)
{
    global $prefix;
    global $bas;
    $cr = new Crawler($start_url);
    /*
    	echo $cr->readline();flush();
    while(!feof($cr->stream)) {
    }
    exit(0);
    */
    $cr->go2linewhere('headerSelect');
    $cr->readline();
    $line = $cr->curline;
    $cr->close();
    $chap = Crawler::cutfromlast1($start_url, '/');
    if (strpos($chap, '.') === false) {
        $chap = Crawler::n($chap, 3);
    } else {
        $a = explode('.', $chap);
        $a[0] = Crawler::n($a[0], 3);
        $chap = implode('.', $a);
    }
    $pi = 1;
    // page i
    $ledak = explode('value="', $line);
    $pages = array();
    for ($i = 1; $i < count($ledak); $i++) {
        $uurl = Crawler::cutuntil($ledak[$i], '"');
        $key = Crawler::cutfromlast1($uurl, '/');
        $pages[$key] = strpos($uurl, 'http://') === 0 ? $uurl : $bas . $uurl;
    }
    //print_r($pages);flush();
    $results = array();
    foreach ($pages as $pagenum => $new_url) {
        $berhasil = false;
        while (!$berhasil) {
            $cr = new Crawler($new_url);
            //echo "URL:$new_url<br/>\n";flush();
            $cr->go2linewhere('id="readerPage"');
            if ($cr->strpos('<img src="') === false) {
                $cr->readline();
            }
            $line = $cr->curline;
            $cr->close();
            $img_url = Crawler::extract($line, '<img src="', '"');
            //echo "IMG:$img_url<br/>\n";flush();
            $real_name = basename($img_url);
            $ext = Crawler::cutfromlast($img_url, '.');
            //$filename = $prefix . '-' . $chap . '-' . Crawler::n($pagenum, 2) . $ext;
            $filename = $prefix . '-' . $chap . '-' . urldecode($real_name);
            $val = $img_url;
            if (!empty($val)) {
                $berhasil = true;
                $key = $filename;
                $results[$filename] = $img_url;
                ?>
				<a href="<?php 
                echo $val;
                ?>
"><?php 
                echo $key;
                ?>
</a><br />
				<?php 
                flush();
            } else {
            }
        }
    }
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:71,代码来源:mangatoshokan.php

示例4: pad

 /**
  * $n: number to be padded
  * $l: goal length
  * $ic: is chapter? if true then "305.5",4 will become "0305.5"
  */
 public static function pad($n, $l, $ic = true)
 {
     if ($ic) {
         if (strpos($n, '.') !== false) {
             $temp = Crawler::cutuntil($n, '.');
             return Crawler::n($temp, $l) . Crawler::cutfrom($n, '.');
         } else {
             return Crawler::n($n, $l);
         }
     } else {
         return Crawler::n($n, $l);
     }
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:18,代码来源:crawler.php

示例5: crawl_page

 public function crawl_page($url, $text)
 {
     echo "Entering '{$url}'<br/>\n";
     flush();
     $c = new Crawler($url, true);
     $dah_gambar = false;
     $i = 1;
     while ($line = $c->readline()) {
         if (preg_match('/pic dashedOn/i', $line)) {
             $dah_gambar = true;
             $line = $c->readline();
             preg_match('/<img src="([^"]+)"/i', $line, $matches);
             $img = $matches[1];
             $tempi = Crawler::n($i++, 3) . substr($img, strrpos($img, '.'));
             echo "<a href='{$img}'>{$text}</a><br/>\n";
             flush();
         } else {
             if (preg_match('/commentButton/i', $line) && $dah_gambar) {
                 break;
             }
         }
     }
     $c->close();
     unset($c);
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:25,代码来源:moko.php

示例6: ichan_realm

function ichan_realm($start_url)
{
    // http://ichan.org/l/res/33005.html
    // <a href="http://c3a56840.linkbucks.com/url/http://ichan.org/l/src/128001023914.jpg">
    $c = new Crawler($start_url);
    $i = 0;
    $c->go_to('class="filesize"');
    while ($line = $c->readline()) {
        if (Crawler::is_there($line, '<a href') && Crawler::is_there($line, 'http://ichan.org/') && Crawler::is_there($line, '/src/')) {
            $raw = Crawler::extract($line, '"', '"');
            $img = preg_replace('/http:\\/\\/[\\w\\.]+\\/url\\//', '', $raw);
            $text = Crawler::n(++$i, 3) . '.jpg';
            echo "<a href='{$img}'>{$text}</a><br/>\n";
        } else {
            if (Crawler::is_there($line, '"footerbg"')) {
                break;
            }
        }
    }
    $c->close();
}
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:21,代码来源:h.php


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