spekulatius / PHPScraper

A universal web-util for PHP.
https://phpscraper.de
GNU General Public License v3.0
509 stars 73 forks source link

TypeError #159

Closed alanx15a2 closed 1 year ago

alanx15a2 commented 1 year ago

When i run the sample code:

$web = new \Spekulatius\PHPScraper\PHPScraper();
$web->go('https://www.google.com/');
echo $web->title;

It return:

Spekulatius\PHPScraper\Core::setHttpClient(): Argument #1 ($httpClient) must be of type Symfony\Component\HttpClient\CurlHttpClient, Symfony\Component\HttpClient\NativeHttpClient given, called in C:\www\web-crawer\vendor\spekulatius\phpscraper\src\PHPScraper.php on line 108

Environments

PHP: 8.1.13 PHPScraper: 1.0.1

spekulatius commented 1 year ago

Ah, I see you want to inject another type of HttpClient?

alanx15a2 commented 1 year ago

Yeah, we use SymfonyHttpClient::create() to create the core. The create() method will return many type of HttpClient, and all of them are implements of HttpClientInterface. So I think we should inject HttpClientInterface here.

spekulatius commented 1 year ago

Yeah, sounds good. I'll merge it in.