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

<?php
require 'vendor/autoload.php';

use SymfonyComponentDomCrawlerCrawler;
use GuzzleHttpClient;

//url 

$url2 = 'https://www.autoscout24.de/lst/audi? 
sort=standard&amp;desc=0&amp;ustate=N%2CU&amp;cy=D&amp;atype=C';

  $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('.cldt-summary-makemodelversion.sc-ellipsis')->text();
    $price = $node->filter('.cldt-price.sc-font-xl.sc-font-bold')->text();
    $details = $node->filter('.cldt-summary-vehicle-data')->text();

    $item = [$title,$price,$details];
    print_r($item);

  });

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

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