Skip to content

Commit

Permalink
Merge pull request #52 from tegansnyder/master
Browse files Browse the repository at this point in the history
Add proxy support and emptyset checks
  • Loading branch information
Swader authored Nov 15, 2016
2 parents c34ae91 + 1d3aeb1 commit 35fda89
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/Api/Crawl.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,19 @@ public function setObeyRobots($bool = true)

return $this;
}

/**
* Set value to 1 to force the use of proxy IPs for the crawl.
*
* @param bool $bool
* @return $this
*/
public function setUseProxies($bool = true)
{
$this->otherOptions['useProxies'] = (int)(bool)$bool;

return $this;
}

/**
* Force the start of a new crawl "round" (manually repeat the crawl).
Expand Down Expand Up @@ -488,13 +501,17 @@ public function buildUrl()
$url .= '&name=' . $this->getName();

// Add seeds
$url .= '&seeds=' . implode(' ', array_map(function ($item) {
if (!empty($this->seeds)) {
$url .= '&seeds=' . implode(' ', array_map(function ($item) {
return urlencode($item);
}, $this->seeds));
}

// Add other options
foreach ($this->otherOptions as $option => $value) {
$url .= '&' . $option . '=' . $value;
if (!empty($this->otherOptions)) {
foreach ($this->otherOptions as $option => $value) {
$url .= '&' . $option . '=' . $value;
}
}

// Add API link
Expand Down

0 comments on commit 35fda89

Please sign in to comment.