Inside the source code of the url I want to scrape I can see this:
<div class="price"> 22.96€ </div>
And this is the php file that I created but it´s not returning any value:
<?php $data_scraped = file_get_contents('https://www.example.com/es/busquedas/?type%5B%5D=steam&query=motogp+20'); $the_start = explode('<div class="price">',$data_scraped); $the_end = explode('</div>',$the_start[1]); echo $the_end[0]; ?>
Any help would be really appreciated
Your question looks similar tothis one which makes use of simple_html_dom for web scraping in PHP.
Restructuring your code for usage with simple_html_dom:
<?php
require 'simple_html_dom.php';
$html = file_get_html('https://www.example.com/es/busquedas/?type%5B%5D=steam&query=motogp+20');
$price = $html->find('div[class=price]');
echo $price->plaintext."<br>";
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.