web scrape using simple html DOM parser

241 views Asked by At

How to extract specific details like name and price of a product from Amazon platform using simple html DOM parser. for example: (product-image, name and price).

1

There are 1 answers

1
Manish On
    $httpClient = new \GuzzleHttp\Client();
$response = $httpClient->get('https://www.floridaleagueofcities.com/research-resources/municipal-directory/');
$htmlString = (string) $response->getBody();

libxml_use_internal_errors(true);
$doc = new DOMDocument();
$doc->loadHTML($htmlString);
$xpath = new DOMXPath($doc);

$titles = $xpath->evaluate('//div[@class="accordion-body"]//ul//li/a');