FriendsOfPHP / Goutte

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

Updated Symfony project - Error "URI must be a string or UriInterface" #276

Open darthink opened 8 years ago

darthink commented 8 years ago

Hello,

I just transferred some web scraping code from an older symfony2 project and now I get the error:

"URI must be a string or UriInterface"

The code I'm using is as follows:

`

       use Goutte\Client;

       $login_url = "https://sub.domain.com/page/login.jsp";

       $client = new Client();
       // The way I used to configure
       // $client->getClient()->setDefaultOption('config/curl/'.CURLOPT_SSL_VERIFYHOST, FALSE);
       // $client->getClient()->setDefaultOption('config/curl/'.CURLOPT_SSL_VERIFYPEER, FALSE);
       $client->getClient()->setDefaultOption(array(
                'curl' => array(
                    CURLOPT_SSL_VERIFYHOST => FALSE,
                    CURLOPT_SSL_VERIFYPEER => FALSE,
                ),
        ));

        // Fill login form and submit
        $crawl_login = $client->request('GET', $login_url); 
        $form = $crawl_login->selectButton('loginSubmit')->form();
        $form['login']    = $user;
        $form['password'] = $pass;
        $crawl_login = $client->submit($form);

`

Here's my Goutte composer.json file to show versions:

`

"require": {
    "php": ">=5.5.0",
    "symfony/browser-kit": "~2.1|~3.0",
    "symfony/css-selector": "~2.1|~3.0",
    "symfony/dom-crawler": "~2.1|~3.0",
    "guzzlehttp/guzzle": "^6.0"
},
"autoload": {
    "psr-4": { "Goutte\\": "Goutte" }
},
"extra": {
    "branch-alias": {
        "dev-master": "3.1-dev"
    }
}

`

It seems Guzzle has updated and uses a lot of new things, and I'm not sure how to get around it. I've been researching the guzzle api for days now. Does goutte still use the commands listed on the home page of instructions? I do not wish to pass an "array" URI and do not wish to do it the "base_uri" new guzzle way. Please help me solve this problem.