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


PHP Crawler::strpos方法代码示例

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


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

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

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

示例3: Crawler

<?php

require_once "crawler.php";
$base = 'http://www.ez-wallpaper.org';
$berhenti = 0;
$url = $base;
while (!$berhenti) {
    echo "\nURL:{$url}\n";
    $c = new Crawler($url);
    $c->readline();
    while ($line = $c->readline()) {
        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) {
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:31,代码来源:ezwall.php

示例4: 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,代码行数:30,代码来源:dilbert.php


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