spekulatius / PHPScraper

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

Make public function to access Client (Goutte) #60

Closed amurrell closed 2 years ago

amurrell commented 2 years ago

I wanted to know the response code of the url but could not get access.

Looking at Goutte under the hood, I think I could get it if I could do something like:

$web->getClient()->getInternalResponse()->getStatusCode()

So, I would like a function to get access to the $client, like:

public function getClient()
{
   return $this->client;
}
spekulatius commented 2 years ago

Hello @amurrell,

How about exposing the response code directly? This would allow to check easily if the navigation was successful...

Cheers, Peter

amurrell commented 2 years ago

Access to the client is really desired - I also need to be able to set the user agent:

In Goutte, you can:

$client->setServerParameter('HTTP_USER_AGENT', 'user agent');
spekulatius commented 2 years ago

Hey @amurrell,

I've added a method to expose the client. You should be able to call it now. Can you check if this works for you?

Cheers, Peter

amurrell commented 2 years ago

@spekulatius This looks perfect.. Will you merge and release it?