FriendsOfPHP / Goutte

Goutte, a simple PHP Web Scraper
MIT License
9.26k stars 1.01k forks source link

GuzzleHttp Client `base_uri` option is being ignored #328

Closed ghost closed 6 years ago

ghost commented 6 years ago

How to reproduce

<?php

$client = new GuzzleClient(['base_uri' => 'https://raw.githubusercontent.com']);
$body = $client->request('get', '/FriendsOfPHP/Goutte/master/box.json')->getBody()->getContents();

Works as expected, but

<?php

$client = new Client();
$client->setClient(new GuzzleClient(['base_uri' => 'https://raw.githubusercontent.com']));
$body = $client->request('get', '/FriendsOfPHP/Goutte/master/box.json')->html();

doesn't work.

Expected

{
    "output": "goutte.phar",
    "chmod": "0755",
    "compactors": [
        "Herrera\\Box\\Compactor\\Php"
    ],
    "extract": false,
    "files": [
        "LICENSE",
        "Goutte/Client.php"
    ],
    "finder": [
        {
            "name": ["*.php", "*.pem*"],
            "exclude": ["Tests", "tests"],
            "in": "vendor"
        }
    ],
    "stub": "Goutte/Resources/phar-stub.php",
    "web": false
}

Actual

<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr>
<center>nginx/1.10.3 (Ubuntu)</center>
</body>

If use var_dump on the object, we can see this:

protected 'uri' => string 'http://localhost/FriendsOfPHP/Goutte/master/box.json'
trinvh commented 6 years ago

Any updates on this?