Skip to content

Commit 35fda89

Browse files
authored
Merge pull request #52 from tegansnyder/master
Add proxy support and emptyset checks
2 parents c34ae91 + 1d3aeb1 commit 35fda89

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/Api/Crawl.php

+20-3
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,19 @@ public function setObeyRobots($bool = true)
365365

366366
return $this;
367367
}
368+
369+
/**
370+
* Set value to 1 to force the use of proxy IPs for the crawl.
371+
*
372+
* @param bool $bool
373+
* @return $this
374+
*/
375+
public function setUseProxies($bool = true)
376+
{
377+
$this->otherOptions['useProxies'] = (int)(bool)$bool;
378+
379+
return $this;
380+
}
368381

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

490503
// Add seeds
491-
$url .= '&seeds=' . implode(' ', array_map(function ($item) {
504+
if (!empty($this->seeds)) {
505+
$url .= '&seeds=' . implode(' ', array_map(function ($item) {
492506
return urlencode($item);
493507
}, $this->seeds));
508+
}
494509

495510
// Add other options
496-
foreach ($this->otherOptions as $option => $value) {
497-
$url .= '&' . $option . '=' . $value;
511+
if (!empty($this->otherOptions)) {
512+
foreach ($this->otherOptions as $option => $value) {
513+
$url .= '&' . $option . '=' . $value;
514+
}
498515
}
499516

500517
// Add API link

0 commit comments

Comments
 (0)