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


PHP Client::request方法代码示例

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


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

示例1: scrap

 public function scrap($username, $password)
 {
     $client = new Client();
     $crawler = $client->request('GET', 'http://studentinfo.bdu.edu.et/login.aspx');
     $form = $crawler->selectButton('Login')->form();
     $form['dnn$ctr$Login$Login_DNN$txtUsername'] = $username;
     $form['dnn$ctr$Login$Login_DNN$txtPassword'] = $password;
     $crawler = $client->submit($form);
     return $client->request('POST', 'MyGrades.aspx');
 }
开发者ID:andegnasoft,项目名称:convert,代码行数:10,代码来源:Scraper.php

示例2: addProduct

 /**
  * Add product data
  *
  * @param Crawler $node
  */
 private function addProduct(Crawler $node)
 {
     $product = new \stdClass();
     /** @var Crawler $title */
     $title = $node->filter('h3 a');
     $product->title = trim($title->text());
     $product->unit_price = $this->getPrice($node->filter('.pricePerUnit'));
     $productCrawler = $this->client->request('GET', $title->attr('href'));
     $product->size = $this->bytesToKb(strlen($this->client->getResponse()->getContent()));
     $product->description = '';
     $description = $productCrawler->filterXPath('//h3[.="Description"]');
     if ($description->count() > 0) {
         foreach ($description->siblings() as $sibling) {
             // product pages have different structures!
             if ($sibling->tagName == 'h3') {
                 break;
             }
             if ($product->description != "") {
                 $product->description .= "\n";
             }
             // @TODO address formatting issues - breaks to new lines
             $product->description .= trim(preg_replace("/[^\\S\r\n]+/", " ", $sibling->nodeValue));
             // remove excess whitespace but not new lines
         }
     }
     $this->total += $product->unit_price;
     // increment total
     $this->results[] = $product;
 }
开发者ID:peterhough,项目名称:sainsburys,代码行数:34,代码来源:Scraper.php

示例3: findById

 /**
  * @param int $id
  *
  * @throws SubjectNotFoundException
  *
  * @return JusticeRecord|false
  */
 public function findById($id)
 {
     Assertion::integer($id);
     $crawler = $this->client->request('GET', sprintf(self::URL_SUBJECTS, $id));
     $detailUrl = $this->extractDetailUrlFromCrawler($crawler);
     if (false === $detailUrl) {
         return false;
     }
     $people = [];
     $crawler = $this->client->request('GET', $detailUrl);
     $crawler->filter('.aunp-content .div-table')->each(function (Crawler $table) use(&$people) {
         $title = $table->filter('.vr-hlavicka')->text();
         try {
             if ('jednatel: ' === $title) {
                 $person = JusticeJednatelPersonParser::parseFromDomCrawler($table);
                 $people[$person->getName()] = $person;
             } elseif ('Společník: ' === $title) {
                 $person = JusticeSpolecnikPersonParser::parseFromDomCrawler($table);
                 $people[$person->getName()] = $person;
             }
         } catch (\Exception $e) {
         }
     });
     return new JusticeRecord($people);
 }
开发者ID:dfridrich,项目名称:ares,代码行数:32,代码来源:Justice.php

示例4: updateShows

 /**
  * Gets all shows and store them in json.
  */
 public function updateShows()
 {
     $url = $this->builder->getAddictedShowsUrl();
     printf("Trying to get shows from [%s].\n", $url);
     $crawler = $this->client->request('GET', $url);
     $showsLinkAndName = $crawler->filter('table.tabel90 > tr > td > h3 > a')->extract(['_text', 'href']);
     $showsSeasons = $crawler->filter('table.tabel90 > tr > td.newsDate')->extract(['_text']);
     if (count($showsLinkAndName) != count($showsSeasons)) {
         throw new \Exception("Inconsistencies detected while updating shows.");
     }
     printf("Found [%s] shows.\n", count($showsLinkAndName));
     $shows = [];
     foreach ($showsLinkAndName as $n => $show) {
         $id = $this->extractShowId($show[1]);
         if ($this->nonEmptyShow($showsSeasons[$n])) {
             $name = Episode::sanitizeShowName($show[0]);
             // if multiple shows name reference the same id
             if (isset($this->mappedShowsNames()[$name])) {
                 foreach ($this->mappedShowsNames()[$name] as $name) {
                     $shows[$name] = $id;
                 }
             } else {
                 $shows[$name] = $id;
             }
         }
     }
     $this->io->saveShows($shows);
 }
开发者ID:alixba,项目名称:addic7ed-subtitles,代码行数:31,代码来源:ShowsUpdater.php

示例5: getCrawler

 public function getCrawler()
 {
     if (!isset($this->crawler)) {
         $this->crawler = $this->client->request('GET', $this->getUri());
     }
     return $this->crawler;
 }
开发者ID:goodhacker,项目名称:marlon-csrfscanner,代码行数:7,代码来源:Page.php

示例6: testLoggedIn

 public function testLoggedIn()
 {
     // we don't use the trait method here since we want our
     // test to span two page requests, and we need to have
     // the session persist on the remote server
     // create a web client and hit the login page
     $url = "http://localhost/login";
     $client = new Client();
     $crawler = $client->request('GET', $url);
     $response_code = $client->getResponse()->getStatus();
     // we should get 200 back
     $this->assertEquals(200, $response_code);
     // select the form on the page and populate values
     // since we are using Goutte\Client, we don't need
     // to worry about parsing the HTML to find the csrf _token
     $form = $crawler->selectButton('Sign in')->form();
     $form->setValues(['email' => 'me@here.ca', 'password' => 'verysecret']);
     // submit the form
     $client->submit($form);
     $response_code_after_submit = $client->getResponse()->getStatus();
     // make sure the HTML page displayed (response code 200
     $this->assertEquals(200, $response_code_after_submit);
     // make sure we can get to the testimonial page
     $client->request('GET', 'http://localhost/add-testimonial');
     $response_code = $client->getResponse()->getStatus();
     $this->assertEquals(200, $response_code);
 }
开发者ID:tcs-udemy,项目名称:introduction-to-unit-testing,代码行数:27,代码来源:LoggedInTest.php

示例7: extractPricesFromTable

 /**
  * Extracts prices from HTML table.
  *
  * @param string $button Submit button text
  * @param array $location Region or county
  * @return array
  */
 protected function extractPricesFromTable($button, array $location)
 {
     $prices = [];
     $crawler = $this->client->request('GET', 'http://www.ccs.cz/pages/phm2.php');
     $form = $crawler->selectButton($button)->form();
     $crawler = $this->client->submit($form, $location);
     $columnIterator = 0;
     $rowIterator = 0;
     $crawler->filter('table[class="dynamic"] td')->each(function (DomCrawler $node) use(&$prices, &$columnIterator, &$rowIterator) {
         switch ($columnIterator) {
             case 0:
                 $prices[$rowIterator]['date'] = new \DateTime($node->text());
                 break;
             case 1:
                 $prices[$rowIterator]['natural95'] = $node->text();
                 break;
             case 3:
                 $prices[$rowIterator]['diesel'] = $node->text();
                 break;
         }
         $columnIterator = ++$columnIterator % 5;
         $rowIterator += $columnIterator == 0 ? 1 : 0;
     });
     return $prices;
 }
开发者ID:havlicek,项目名称:ccs-crawler,代码行数:32,代码来源:Crawler.php

示例8: request

 /**
  * Requests a URL.
  *
  * @param  string $url    The URL to request
  * @param  string $method The HTTP method
  * @return Crawler
  * @throws ConnectException
  */
 private function request($url, $method = 'GET')
 {
     try {
         return $this->client->request(strtoupper($method), $url);
     } catch (ConnectException $error) {
         throw $error;
     }
 }
开发者ID:REBELinBLUE,项目名称:sainsburys,代码行数:16,代码来源:Scraper.php

示例9: scrape

 /**
  * @param Url $url
  *
  * @return \Symfony\Component\DomCrawler\Crawler|null
  */
 public function scrape(Url $url)
 {
     try {
         return $this->client->request('GET', $url->getUrl());
     } catch (RequestException $e) {
         return;
     }
 }
开发者ID:cirpo,项目名称:sainsburys-scraper,代码行数:13,代码来源:Scraper.php

示例10: scrap

 private function scrap(Song $song)
 {
     $arr = [];
     $crawler = $this->client->request('GET', $song->url());
     $arr["title"] = $crawler->filter("title")->text();
     $arr["thumbnail_url"] = sprintf('http://img.youtube.com/vi/%s/1.jpg', $song->videoId());
     return $arr;
 }
开发者ID:uirapuru,项目名称:playlist,代码行数:8,代码来源:TitleProvider.php

示例11: actionIndex

 public function actionIndex()
 {
     /** @var $entity RivegaucheLink */
     $entity = new RivegaucheLink();
     $offset = 0;
     do {
         $links = $entity->getLinks($offset, 5);
         if (!empty($links)) {
             foreach ($links as $link) {
                 \Yii::info(sprintf('Обрабатываем: %s ', $link['link']), 'cron');
                 $client = new Client();
                 $guzzle = $client->getClient();
                 $client->getClient()->setDefaultOption('config/curl/' . CURLOPT_PROXY, 'http://141.101.118.147:80');
                 //$client->getClient()->setDefaultOption('config/curl/'.CURLOPT_TIMEOUT, 10);
                 $client->getClient()->setDefaultOption('config/curl/' . CURLOPT_CONNECTTIMEOUT, 10);
                 $client->setClient($guzzle);
                 /*$guzzle = $client->getClient();
                                     $guzzle->setDefaultOption('timeout', 10);
                 
                                     $client->getClient()->setDefaultOption('config/curl/'.CURLOPT_TIMEOUT_MS, 100);
                                     $client->getClient()->setDefaultOption('config/curl/'.CURLOPT_CONNECTTIMEOUT, 5);
                                     $client->getClient()->setDefaultOption('config/curl/'.CURLOPT_RETURNTRANSFER, true);
                                     $client->setClient($guzzle);*/
                 $crawler = $client->request('GET', $link['link']);
                 \Yii::info(sprintf('Извлекаем тело: %s ', $link['link']), 'cron');
                 $head = $this->getHtml($crawler, true);
                 \Yii::info(sprintf('HEAD тело: %s ', $link['link']), 'cron');
                 if (!empty($head['links'])) {
                     foreach ($head['links'] as $l) {
                         $crawler = $client->request('GET', $l);
                         $subHead = $this->getHtml($crawler, false);
                         $subHead['link'] = $l;
                         $this->saveResult($subHead, $link);
                     }
                 }
                 if (empty($head['title'])) {
                     $head = $this->getPromoHTML($crawler, true);
                 }
                 if (empty($head['title'])) {
                     $head = $this->getPromo2HTML($crawler, true);
                 }
                 $head['link'] = $link['link'];
                 $this->saveResult($head, $link);
                 unset($node);
                 unset($subNode);
                 unset($head);
             }
             $z = 1;
             $offset += 5;
             unset($links);
             unset($client);
         } else {
             $z = 0;
         }
     } while ($z > 0);
     return 0;
 }
开发者ID:Ellumilel,项目名称:analitics,代码行数:57,代码来源:RivegaucheProductController.php

示例12: isValidCard

 /**
  * Checks at the NABV site if the given card is correct
  * @param Card $card
  *
  * @return bool
  */
 public function isValidCard(Card $card)
 {
     $crawler = $this->client->request('POST', $this->url, ['relation_number' => $card->toString()]);
     $status = false;
     $crawler->filter('.alert.alert-success')->each(function () use(&$status) {
         $status = true;
     });
     return $status;
 }
开发者ID:verschoof,项目名称:nabv-cardcheck,代码行数:15,代码来源:CardValidator.php

示例13: extractEntries

 /**
  * Extract entries from given crawler object.
  *
  * @param \Symfony\Component\DomCrawler\Crawler $crawler
  * @return array
  */
 public function extractEntries(Crawler $crawler)
 {
     $links = $this->linksExtractor->extractEntries($crawler);
     $entries = array();
     if (count($links)) {
         foreach ($links as $link) {
             $entries[] = $this->entryExtractor->extractEntry($this->client->request('GET', $link));
         }
     }
     return $entries;
 }
开发者ID:dataintegration,项目名称:provider-goutte,代码行数:17,代码来源:DeeplinkEntriesExtractor.php

示例14: request

 /**
  * @param Client $client
  */
 public function request(Client $client)
 {
     if (isset($this->provider)) {
         $class = static::$providers[$this->provider];
         if (isset($class::$endpoint)) {
             $client->request('GET', $class::$endpoint . rawurlencode($this->url));
             $this->content = json_decode($client->getResponse()->getContent());
         } else {
             $this->content = $client->request('GET', $this->url);
         }
     }
 }
开发者ID:jamband,项目名称:ripple,代码行数:15,代码来源:Ripple.php

示例15: checkContribution

 /**
  * その日に草が生えてるかをチェックする
  *
  * @param string $userName
  *
  * @return bool
  */
 public function checkContribution($userName)
 {
     // Getting user page souce
     $body = $this->goutteClient->request('GET', $this->getGitHubUrl($userName));
     // parse response body
     $contribution = null;
     $body->filter('rect')->last()->each(function ($name) {
         $contribution = $name->attr('fill');
     });
     // #eeeeeeはSaboってる
     return $contribution !== '#eeeeee';
 }
开发者ID:illuminate3,项目名称:Saborunayo,代码行数:19,代码来源:GitHubService.php


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