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


PHP Crawler::count方法代码示例

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


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

示例1: parse

 public function parse($url)
 {
     $chunks = parse_url($url);
     if ($chunks['path'] !== Urls::URL_ALBUM) {
         $this->logger->error('Unknown URL received');
         return;
     }
     $host = $chunks['host'];
     $schema = $chunks['scheme'];
     $this->logger->info('Resolved host and schema', ['host' => $host, 'schema' => $schema]);
     $this->logger->info('Fetching url', ['url' => $url]);
     $response = $this->guzzle->get($url);
     $this->logger->info('Fetched first page', ['url' => $url]);
     $crawler = new Crawler((string) $response->getBody());
     $links = $crawler->filter(Selectors::SELECTOR_PAGINATION_NUMBER_LINKS);
     $pages = [];
     for ($i = 0; $i < $crawler->count(); $i++) {
         $link = $links->eq($i);
         $chunks = parse_url($link->attr('href'));
         parse_str($chunks['query'], $query);
         $pages[] = $query['page'];
     }
     $this->logger->info('', ['pages' => $pages]);
 }
开发者ID:entership,项目名称:srany-parser,代码行数:24,代码来源:ParserLauncher.php

示例2: getFieldValue

 /**
  * Return the field's value
  *
  * @param $node
  * @param $defaultValue
  * @param $callback
  * @param string $funcName
  * @param string $funcParam
  *
  * @return mixed
  */
 private function getFieldValue(Crawler $node, $defaultValue, $callback, $funcName = 'text', $funcParam = '')
 {
     if ($node->count()) {
         return $callback($node->{$funcName}($funcParam));
     }
     return $defaultValue;
 }
开发者ID:rfussien,项目名称:leboncoin-crawler,代码行数:18,代码来源:SearchResultAdCrawler.php

示例3: getPaginationInfo

 private function getPaginationInfo(Crawler $info)
 {
     $result = new \stdClass();
     switch ($info->count()) {
         case 0:
             // no results
             $result->total_results = 0;
             $result->results_per_page = 10;
             // (last item - first) + 1 => Items 21 -> 40 => 40-21+1 = 20 items.
             $result->num_pages = 0;
             $result->first_on_page = 0;
             $result->last_on_page = 0;
             $result->current_page = 0;
             break;
         case 1:
             $aux = explode(PHP_EOL, $info->text());
             $info = array_pop($aux);
             $info = explode(' ', $info);
             $result->total_results = intval($info[4]);
             $result->results_per_page = intval($info[2]) - intval($info[0]) + 1;
             // (last item - first) + 1 => Items 21 -> 40 => 40-21+1 = 20 items.
             $result->num_pages = intval(ceil($result->total_results / $result->results_per_page));
             $result->first_on_page = intval($info[0]);
             $result->last_on_page = intval($info[2]);
             $result->current_page = intval(ceil($result->first_on_page / $result->results_per_page));
             break;
     }
     return $result;
 }
开发者ID:vgomes,项目名称:daftapi,代码行数:29,代码来源:DaftOverseas.php

示例4: count

 /**
  * Length of items in document
  *
  * @group Iterator
  */
 public function count()
 {
     return $this->crawler->count();
 }
开发者ID:aakb,项目名称:bpi-client,代码行数:9,代码来源:Document.php


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