PHPScraper icon indicating copy to clipboard operation
PHPScraper copied to clipboard

Make public function to access Client (Goutte)

Open amurrell opened this issue 3 years ago • 4 comments

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;
}

amurrell avatar Jan 09 '22 06:01 amurrell

Hello @amurrell,

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

Cheers, Peter

spekulatius avatar Jan 11 '22 11:01 spekulatius

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');

amurrell avatar Jan 19 '22 22:01 amurrell

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

spekulatius avatar Jan 23 '22 15:01 spekulatius

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

amurrell avatar Mar 14 '22 18:03 amurrell