コード例 #1
0
 public function testRemove()
 {
     $website1 = $this->createWebsite();
     $website2 = $this->createWebsite();
     $website3 = $this->createWebsite();
     $websites = [$website1, $website2, $website3];
     $websiteCollection = new WebsiteCollection($websites);
     $websiteCollection->removeElement($website1);
     $this->assertEquals($websiteCollection->count(), 2);
     $this->assertEquals($websiteCollection[1], $website2);
 }
コード例 #2
0
ファイル: GoogleEngine.php プロジェクト: seotracker/seo-core
 /**
  * @return WebsiteCollection $websites a collection a websites
  */
 public function getWebsites($needle, $limit)
 {
     $url = $this->getRootUrl() . "q={$needle}&gbv=1&num={$limit}";
     $content = $this->scrapper->get($url);
     $crawler = $this->crawler->setContent($content);
     $links = $crawler->get('#res li.g > h3 > a');
     $websites = new WebsiteCollection();
     foreach ($links as $position => $link) {
         $fullLocation = $link->getAttribute('href');
         $location = $this->cleanUrl(substr($fullLocation, 7));
         $websites->add($this->getWebsite($location));
     }
     return $websites;
 }