0

everyone, this is my first question since I join StackOverflow. sorry if my English isn't good. now I'm doing some task using Codeigniter. this task required scraping function. when I am googling, I find this https://github.com/FriendsOfPHP/Goutte. I still confuse how to implement goutte into Codeigniter. I already install composer and run

composer require fabpot/goutte

and I created a controller and name it with Scraping.php. the code like this

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

use Goutte\Client;

class Scraping extends MY_Controller {

    public function __construct(){
        parent::__construct();
    }

    public function index() {

      $client = new Client();
       $crawler = $client->request('GET', 'https://www.agoda.com/hotel-eucalyptus/hotel/santorini-gr.html'); 
       $crawler->filter('.FirstTileContent__Header')->each(function ($node) {
          dump($node->text());
      });

    }
}

but the result is

An uncaught Exception was encountered
Type: Error

Message: Class 'Goutte\Client' not found

and in confuse how should I fix it. please.

Nimesh Patel
  • 796
  • 1
  • 7
  • 23
jhonathan
  • 1
  • 4

0 Answers0