acquisition of Amazon prices

Asked 2 years ago, Updated 2 years ago, 88 views

http://www.amazon.co.jp/dp/4822242633
for the individual Amazon product page. I think there are many ways to extract only the price of the product by using , but how will you achieve this?
I would appreciate it if you could let me know.
*Please use PHP as the language.
*Amazon api has a request limitation, so please use something other than amazon api.
*The price of the product is the tag part below.

<span class="a-size-medium a-color-price offer-price a-text-normal">¥2,376</span>

Thank you for your cooperation.

javascript php api

2022-09-30 19:35

1 Answers

<?php
$html=file_get_contents("http://www.amazon.co.jp/dp/4822242633");

$dom = new DOMDocument();
@$dom->loadHTML ($html);
$xml = simplexml_import_dom($dom);
$ret=$xml->xpath('//span [@class="a-size-medium a-color-price offer a-text-normal"]');
echo$ret[0];
?>

This is the only way to extract it with Xpath.

This Qiita article is useful for scraping in PHP.
Introduction to scraping with native SPHP DOM - Qiita


2022-09-30 19:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.