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


PHP Client::getHistory方法代码示例

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


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

示例1: ensureLoggedIn

 public function ensureLoggedIn()
 {
     $crawler = $this->client->request('GET', '/user/login');
     /** @var Response $response */
     $response = $this->client->getResponse();
     if ($response->getStatus() < 200 && $response->getStatus() >= 300) {
         return;
     }
     $loginForm = $crawler->filter('#loginPageForm')->form();
     $this->client->submit($loginForm, ['username' => $this->username, 'password' => $this->password]);
     if (strpos($this->client->getHistory()->current()->getUri(), 'account') === FALSE) {
         throw new \PHPUnit_Framework_Exception("Should be logged in, but is not.");
     }
 }
开发者ID:brennantom,项目名称:hackazon,代码行数:14,代码来源:WebTestCase.php

示例2: execute

 /**
  * @param InputInterface  $input  The input instance
  * @param OutputInterface $output The output instance
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pages = 25;
     $page = 1;
     $output->writeln('<info>Beginning Google crawl</info>');
     $query = new QueryString(array('q' => 'site:drupalcode.org "composer.json" "drupal-module"'));
     $url = 'http://www.google.com/search?' . $query;
     // Load page 1
     $client = new Client();
     $crawler = $client->request('GET', $url);
     $repos = array();
     // Crawl through search pages.
     do {
         $current = $client->getHistory()->current()->getUri();
         $output->writeln('<info>Crawling:</info> ' . $current);
         // Use a CSS filter to select only the result links:
         $links = $crawler->filter('li h3 a');
         // Search the links for the domain:
         foreach ($links as $index => $link) {
             $href = $link->getAttribute('href');
             $query = QueryString::fromString(parse_url($href, PHP_URL_QUERY));
             $url = $query->get('q');
             // Match pages with composer.json in root.
             if (preg_match('/^http:\\/\\/drupalcode.org.+\\.git\\/.+\\/composer.json$/i', $url)) {
                 // Strip to git url and rewrite to drupalcode.org then store unique matches.
                 $matches = array();
                 preg_match('/^http:\\/\\/drupalcode.org.+\\.git/i', $url, $matches);
                 $repo = str_replace('http://drupalcode.org/', 'http://git.drupal.org/', $matches[0]);
                 $repos[$repo] = null;
                 $output->writeln('<info>Found:</info> ' . $repo);
             }
         }
         // Turn the page.
         $page++;
         $node = $crawler->filter('table#nav')->selectLink($page);
         if ($node->count()) {
             $crawler = $client->click($node->link());
         } else {
             break;
         }
     } while ($page < $pages);
     $path = getcwd() . '/satis.json';
     $file = new JsonFile($path);
     $data = $file->read();
     foreach ($data['repositories'] as $file_repo) {
         $repos[$file_repo['url']] = null;
     }
     $repos = array_keys($repos);
     sort($repos);
     $data['repositories'] = array();
     foreach ($repos as $repo) {
         $data['repositories'][] = array('url' => $repo, 'type' => 'vcs');
     }
     $file->write((array) $data);
 }
开发者ID:glennpratt,项目名称:drupal-satis,代码行数:59,代码来源:CrawlCommand.php

示例3: run

 /**
  * @param $testId
  * @param int $operationId
  * @param array $testData
  * @return array
  */
 public function run($testId, $operationId = 0, $testData = [])
 {
     //$opData = $testData['operations'][$operationId];
     $orderId = $testData['orderId'];
     // Log in
     $crawler = $this->client->request('GET', $this->host . '/user/login');
     $loginFormNode = $crawler->filter('#loginPageForm');
     $loginForm = $loginFormNode->form();
     $this->client->submit($loginForm, ['username' => $this->username, 'password' => $this->password]);
     // Find a page with transaction form and submit it (override in subclasses)
     $crawler = $this->submitTransactionForm($orderId);
     //var_dump($this->client->getHistory(), parse_url($this->client->getHistory()->current()->getUri())); exit;
     // Go home
     $homeForm = $crawler->filter('form')->first()->form();
     $result = ['ACTION' => $homeForm->get('ACTION')->getValue(), 'RC' => $homeForm->get('RC')->getValue(), 'TRTYPE' => $homeForm->get('TRTYPE')->getValue(), 'RRN' => $homeForm->get('RRN')->getValue(), 'operation' => $operationId, 'test' => $testId, 'ORDER' => $homeForm->get('ORDER')->getValue(), 'date' => date('m/d/Y')];
     $this->client->submit($homeForm);
     ob_start();
     var_dump($this->client->getHistory());
     $result['history'] = ob_get_clean();
     return $result;
 }
开发者ID:nchervyakov,项目名称:evolve2,代码行数:27,代码来源:BaseTest.php

示例4: getCategoryById

 /**
  * @param int $categoryId
  * @return Category
  */
 public function getCategoryById($categoryId)
 {
     $url = 'http://www.tunisianet.com.tn/' . $categoryId . '-';
     $crawler = $this->client->request('GET', $url);
     $url = $this->client->getHistory()->current()->getUri();
     $title = $crawler->filter('title')->text();
     $products = $crawler->filter('#produit_liste_main .ajax_block_product')->each(function (Crawler $node) {
         $title = $node->filter('.center_block > h2 > a')->text();
         $id = intval($node->filter("input[id^='hit_id']")->attr('value'));
         $reference = $node->filter("input[id^='hit_ref']")->attr('value');
         $description = $node->filter('.center_block > .product_desc > a')->text();
         $priceTag = $node->filter('.price')->text();
         $price = floatval(str_replace(',', '.', $priceTag));
         $available = $node->filter('#produit_liste_prix > div:nth-child(2)')->attr('class') === 'en_stock';
         $url = $node->filter('.center_block > h2 > a')->attr('href');
         $product = new Product($id, $title, $reference, $description, $price, $available, $url);
         return $product;
     });
     $category = new Category($categoryId, $title, $url, $products);
     return $category;
 }
开发者ID:aminebenhariz,项目名称:TunisianetScraper,代码行数:25,代码来源:Scraper.php


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