Saving data in a Mysql database using Symfony

I am new to Symfony and I am trying t save some data in a MySQL DB, I scrapped some data from a website and I need to save each row of the data in the database

require 'vendor/autoload.php';

use SymfonyComponentDomCrawlerCrawler;
use GuzzleHttpClient;


$url2 = ' 

  $client2 = new GuzzleHttpClient();

  $res2 = $client2->request('GET',$url2, ['verify' => false]);

  $html2 = ''.$res2->getBody();

  $crawler2 = new Crawler($html2);

  $crawler2 = $crawler2->filter('body');

   $nodeValues = $crawler2->filter('.cl-list-element > div')->each(function (Crawler $node, $i) {
   // echo $node->html();

    $title = $node->filter('')->text();
    $price = $node->filter('')->text();
    $details = $node->filter('.cldt-summary-vehicle-data')->text();

    $item = [$title,$price,$details];


Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *