Good day. There is a need for parsing the Yandex.Market page (nothing criminal, though - just a test task). I use symfony / dom-crawler, html I get through curl:
function getHTML(string $url): string { $optionsArray = array( CURLOPT_AUTOREFERER => true, CURLOPT_COOKIESESSION => false, CURLOPT_HTTPGET => true, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_FOLLOWLOCATION => true, CURLOPT_BINARYTRANSFER => true, ); $ch = curl_init($url); curl_setopt_array($ch, $optionsArray); $result = curl_exec($ch); curl_close($ch); if($result === false) { throw new \InvalidArgumentException('Cant load HTML'); } else { return $result; }} The description of the product and other things is something like this:
$products = $crawler->filter(".n-snippet-card2")->each(function(Crawler $node, $i){ $currentProduct['title'] = trim($node->filter(".n-snippet-card2__title a")->text()); $currentProduct['price'] = trim($node->filter(".price")->text()); $currentProduct['about'] = trim($node->filter(".n-snippet-card2__content")->text()); return $currentProduct; }); There was a question about parsing pictures: is there any more adequate way to pull out pictures, except for how to take url pictures from the "img" tag, download a picture on this url and write to the database? Thanks in advance for the answers.