guzzle / guzzle

Guzzle, an extensible PHP HTTP client

Home Page:https://docs.guzzlephp.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could guzzle get response redirected by javascript?

joe820912boy opened this issue · comments

Guzzle version: 7
PHP version: 8.15

When I get some url, and it redirect by the javascript with attribute like "top.location", or "refresh"
and I could see the redirect code with 301,
but when I use $res->getStatusCode() it only show 200 from the current url.

I have seen that guzzlehttp wouldn't execute any js, so it means that I couldn't get the correct page?

So that how do I get the final url when this situation occurs? Or someone face the same problem before?

No, we do not evaluate JS. We are an HTTP client, not a web browser.

We do follow redirects by default though. If we see a 301 or 302 status response with a valid Location header, we will follow that, possibly dropping some headers & cookies (for security) along the way, and you only see the final response.