Skip to content

Commit

Permalink
Adding support to proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
nathabonfim59 authored and spekulatius committed Oct 10, 2022
1 parent 68ddb90 commit 326bdff
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/phpscraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// https://github.com/Donatello-za/rake-php-plus
use DonatelloZa\RakePlus\RakePlus;

// https://symfony.com/doc/current/http_client.html
use Symfony\Component\HttpClient\HttpClient;

class phpscraper
{
/**
Expand Down Expand Up @@ -98,6 +101,23 @@ public function __construct()
);
}

/**
* Sets a http proxy
*
* @param string $proxy
*/
public function setProxy(string $proxy)
{
$httpClient = HttpClient::create([
'proxy' => $proxy
]);

// Goutte Client
$this->client = new Client($httpClient);

return $this;
}

/**
* Overwrites the agent
*
Expand Down

0 comments on commit 326bdff

Please sign in to comment.