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


PHP Crawler::selectLink方法代码示例

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


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

示例1: getDetails

 /**
  * Gets the details page.
  *
  * @return Crawler
  * @todo Refactor this as it is not possible to mock currently
  */
 private function getDetails()
 {
     if (is_null($this->details)) {
         $url = $this->crawler->selectLink($this->getTitle())->link()->getUri();
         $scraper = new Scraper();
         $this->details = $scraper->fetch($url);
         $this->length = $scraper->getResponseSize();
     }
     return $this->details;
 }
开发者ID:REBELinBLUE,项目名称:sainsburys,代码行数:16,代码来源:ProductParser.php

示例2: dontSeeLink

 public function dontSeeLink($text, $url = null)
 {
     $links = $this->crawler->selectLink($text);
     if ($url) {
         $links = $links->filterXPath(sprintf('.//a[contains(@href, %s)]', Crawler::xpathLiteral($url)));
     }
     $this->assertDomNotContains($links, 'a');
 }
开发者ID:Eli-TW,项目名称:Codeception,代码行数:8,代码来源:InnerBrowser.php

示例3: dontSeeLink

 public function dontSeeLink($text, $url = null)
 {
     $links = $this->crawler->selectLink($this->escape($text));
     if (!$url) {
         \PHPUnit_Framework_Assert::assertEquals(0, $links->count(), "'{$text}' on page");
     }
     $links->filterXPath(sprintf('descendant-or-self::a[contains(@href, "%s")]', Crawler::xpathLiteral(' ' . $this->escape($url) . ' ')));
     \PHPUnit_Framework_Assert::assertEquals(0, $links->count());
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:9,代码来源:Framework.php

示例4: click

 /**
  * Click a link with the given body, name, or ID attribute.
  *
  * @param  string  $name
  * @return $this
  */
 protected function click($name)
 {
     $link = $this->crawler->selectLink($name);
     if (!count($link)) {
         $link = $this->filterByNameOrId($name, 'a');
         if (!count($link)) {
             throw new InvalidArgumentException("Could not find a link with a body, name, or ID attribute of [{$name}].");
         }
     }
     $this->visit($link->link()->getUri());
     return $this;
 }
开发者ID:hanifn,项目名称:laravel-framework,代码行数:18,代码来源:InteractsWithPages.php

示例5: iClickTheLink

 /**
  * @When /^I click the ([^"]*) link in the e-?mail$/
  */
 public function iClickTheLink($linkText)
 {
     if (empty($this->email)) {
         throw new \Exception('No email to click through from.');
     }
     $crawler = new Crawler();
     $crawler->addHtmlContent($this->email['htmlContent']['htmlBody']);
     try {
         $href = $crawler->selectLink($linkText)->attr('href');
     } catch (\InvalidArgumentException $e) {
         throw new \Exception("No link with text '{$linkText}' found in email.");
     }
     $this->getSession()->visit($href);
 }
开发者ID:tableau-mkt,项目名称:eloqua-bdd,代码行数:17,代码来源:Email.php

示例6: doAlunoLogin

 /**
  *  Does login with ID and password.
  **/
 public function doAlunoLogin()
 {
     // get csrf token
     $this->crawler = $this->client->request('GET', $this->endpoint);
     $token = $this->crawler->filter('input[name="csrfmiddlewaretoken"]');
     $token = $token->attr('value');
     // get form and submit
     $form = $this->crawler->selectButton('Acessar')->form();
     $this->crawler = $this->client->submit($form, ['username' => $this->username, 'password' => $this->password, 'csrfmiddlewaretoken' => $token]);
     // get matricula number
     $meusdados_link = $this->crawler->selectLink('Meus Dados')->link()->getUri();
     $link_parts = explode('/', $meusdados_link);
     $this->matricula = $link_parts[5];
 }
开发者ID:ivmelo,项目名称:suapclient,代码行数:17,代码来源:SUAP.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var FormatterHelper $formatter */
     $formatter = $this->getHelper('formatter');
     $html = file_get_contents('http://spb.hh.ru/search/vacancy?text=php&clusters=true&enable_snippets=true');
     $crawler = new Crawler($html, 'http://spb.hh.ru/search/vacancy?text=php&clusters=true&enable_snippets=true');
     $output->writeln($formatter->formatBlock('Vacancies', 'question', true));
     $crawler->filterXPath(CssSelector::toXPath('body a.search-result-item__name'))->each(function (Crawler $node) use($output) {
         $output->writeln(sprintf('<comment>%s</comment>', $node->text()));
     });
     $data = $crawler->filter('body a.search-result-item__name')->extract(['_text', 'class']);
     print_r($data[0]);
     $output->writeln($formatter->formatBlock('Link test', 'question', true));
     $link = $crawler->selectLink('PHP developer')->link();
     $output->writeln($link->getUri());
     $crawler = new Crawler(file_get_contents('http://spb.hh.ru/login'), 'http://spb.hh.ru/login');
     $output->writeln($formatter->formatBlock('Form test', 'question', true));
     $form = $crawler->selectButton('Войти')->form(['username' => 'name', 'password' => 'pass']);
     $output->writeln($form->getUri());
     $form['remember']->tick();
     $output->writeln(print_r($form->getPhpValues()));
 }
开发者ID:GrizliK1988,项目名称:symfony-certification-prepare-project,代码行数:22,代码来源:DomCrawlerHHTestCommand.php

示例8: testSelectLinkAndLinkFiltered

    public function testSelectLinkAndLinkFiltered()
    {
        $html = <<<HTML
<!DOCTYPE html>
<html lang="en">
<body>
    <div id="action">
        <a href="/index.php?r=site/login">Login</a>
    </div>
    <form id="login-form" action="/index.php?r=site/login" method="post">
        <button type="submit">Submit</button>
    </form>
</body>
</html>
HTML;
        $crawler = new Crawler($html);
        $filtered = $crawler->filterXPath("descendant-or-self::*[@id = 'login-form']");
        $this->assertCount(0, $filtered->selectLink('Login'));
        $this->assertCount(1, $filtered->selectButton('Submit'));
        $filtered = $crawler->filterXPath("descendant-or-self::*[@id = 'action']");
        $this->assertCount(1, $filtered->selectLink('Login'));
        $this->assertCount(0, $filtered->selectButton('Submit'));
        $this->assertCount(1, $crawler->selectLink('Login')->selectLink('Login'));
        $this->assertCount(1, $crawler->selectButton('Submit')->selectButton('Submit'));
    }
开发者ID:sapwoo,项目名称:portfolio,代码行数:25,代码来源:CrawlerTest.php

示例9: test_getLink

 public function test_getLink()
 {
     $link = $this->decorator->getLink();
     $crawler = new Crawler($link);
     $this->assertEquals($this->decorator->getUrl(), $crawler->selectLink("Term 1")->attr('href'));
 }
开发者ID:maxcal,项目名称:wordpress-decorators,代码行数:6,代码来源:CategoryDecoratorTest.php

示例10: getNextLink

 /**
  * @param SymfonyCrawler $crawler
  * @return \Symfony\Component\DomCrawler\Link|null
  */
 protected function getNextLink(SymfonyCrawler $crawler)
 {
     $linkNode = $crawler->selectLink('След');
     return count($linkNode) ? $linkNode->link() : null;
 }
开发者ID:athlonUA,项目名称:xakep-crawler,代码行数:9,代码来源:Crawler.php

示例11: Crawler

 function test_Link()
 {
     $link = $this->decorator->link;
     $crawler = new Crawler($link);
     $this->assertEquals($this->decorator->url, $crawler->selectLink('Post title 1')->attr('href'));
 }
开发者ID:maxcal,项目名称:wordpress-decorators,代码行数:6,代码来源:PostDecoratorTest.php

示例12: pagination

 /**
  * @param Crawler $crawler
  * @return boolean|Crawler
  * TODO: Поиск записей по всем доступным страницам.
  */
 protected function pagination(Crawler $crawler)
 {
     $nextPageCrawler = $crawler->selectLink('След.');
     if ($nextPageCrawler && $nextPageCrawler->getNode(0) && false === mb_stripos($nextPageCrawler->getNode(0)->getAttribute('class'), 'ui-disabled', null, 'UTF-8')) {
         return self::$client->click($nextPageCrawler->link());
     }
     return false;
 }
开发者ID:Gemorroj,项目名称:forum,代码行数:13,代码来源:ForumWebTestCase.php

示例13: iGoToInTheEmail

 /**
  * Assumes an email has been identified by a previous step,
  * e.g. through 'Given there should be an email to "test@test.com"'.
  * 
  * @When /^I click on the "([^"]*)" link in the email"$/
  */
 public function iGoToInTheEmail($linkSelector)
 {
     if (!$this->lastMatchedEmail) {
         throw new \LogicException('No matched email found from previous step');
     }
     $match = $this->lastMatchedEmail;
     $crawler = new Crawler($match->Content);
     $linkEl = $crawler->selectLink($linkSelector);
     assertNotNull($linkEl);
     $link = $linkEl->attr('href');
     assertNotNull($link);
     return new Step\When(sprintf('I go to "%s"', $link));
 }
开发者ID:helpfulrobot,项目名称:silverstripe-behat-extension,代码行数:19,代码来源:EmailContext.php

示例14: clickLink

 /**
  * Clicks a link
  *
  * @param Crawler $crawler
  * @param string $where Translation key of the link text
  *
  * @return Crawler
  */
 public static function clickLink(Crawler $crawler, $where)
 {
     $link = $crawler->selectLink(self::$translator->trans($where));
     return self::$client->click($link->link());
 }
开发者ID:abienvenu,项目名称:kyela,代码行数:13,代码来源:PollWebTestCase.php


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