/**
  * Check for valid scraping args.
  * @param  array  $keywords
  * @param  int    $pagesToScrape
  * @param  bool   $toRemove
  * @param  string $timezone
  * @param  bool   $throttling
  * @param  array  $trackingKeywords
  * @return bool
  */
 public static function validScrapeArgs($keywords, $pagesToScrape, $toRemove, $timezone, $throttling, $trackingKeywords)
 {
     return \Franzip\SerpScraper\Helpers\KeywordValidator::validKeywords($keywords) && self::keywordsAllTracked($keywords, $trackingKeywords) && is_int($pagesToScrape) && $pagesToScrape > 0 && is_bool($toRemove) && in_array($timezone, \DateTimeZone::listIdentifiers()) && is_bool($throttling);
 }
 protected function setUp()
 {
     $engines = array('google', 'bing', 'yahoo', 'ask');
     $offsets = array(0, 1, 2, 3, 4, 5, 6);
     $keywords = array(Validator::processKeyword('foobar'), Validator::processKeyword('foo'), Validator::processKeyword('foo baz  ?  \\/  <>'), Validator::processKeyword('\\n\\t/   <a>'));
     $this->settings = array('engines' => $engines, 'offsets' => $offsets, 'keywords' => $keywords);
 }
Exemple #3
0
 /**
  * Add multiple keywords to scrape.
  * @param   array $keywords
  * @return  bool
  */
 public function addKeywords($keywords)
 {
     if (KeywordValidator::validKeywords($keywords) && !empty($keywords)) {
         for ($i = 0; $i < count($keywords); $i++) {
             $this->addKeyword($keywords[$i]);
         }
         return true;
     }
     return false;
 }