Test NUC
This commit is contained in:
@@ -73,7 +73,7 @@ class CountryCompareController extends Controller
|
|||||||
//dd($response)
|
//dd($response)
|
||||||
switch ($country) {
|
switch ($country) {
|
||||||
case "BG":
|
case "BG":
|
||||||
case "BY":
|
case "CY":
|
||||||
case "GR":
|
case "GR":
|
||||||
$prices[$country] = $this->parseJson_CY_GR_BG($code, (string) $response, $country);
|
$prices[$country] = $this->parseJson_CY_GR_BG($code, (string) $response, $country);
|
||||||
break;
|
break;
|
||||||
@@ -107,9 +107,9 @@ class CountryCompareController extends Controller
|
|||||||
public function parseJson($json_raw, $country)
|
public function parseJson($json_raw, $country)
|
||||||
{
|
{
|
||||||
$json_values = array();
|
$json_values = array();
|
||||||
|
Log::info('{json_raw} {country}', [$json_raw, $country]);
|
||||||
$json_decoded = json_decode($json_raw, true);
|
$json_decoded = json_decode($json_raw, true);
|
||||||
//dd($json_decoded);
|
|
||||||
$searchResultPage = $json_decoded["searchResultPage"];
|
$searchResultPage = $json_decoded["searchResultPage"];
|
||||||
$products = $searchResultPage["products"];
|
$products = $searchResultPage["products"];
|
||||||
$main = $products["main"];
|
$main = $products["main"];
|
||||||
@@ -138,9 +138,9 @@ class CountryCompareController extends Controller
|
|||||||
//echo "country: " . $country . ", code: " . $code . "<br>";
|
//echo "country: " . $country . ", code: " . $code . "<br>";
|
||||||
|
|
||||||
$dochtml = new \DOMDocument();
|
$dochtml = new \DOMDocument();
|
||||||
@$dochtml->loadHTML('<?xml encoding="UTF-8">' . $body);
|
@$dochtml->loadHTML( $body);
|
||||||
|
|
||||||
$xpath = new \DOMXpath($dochtml);
|
@$xpath = new \DOMXpath($dochtml);
|
||||||
$price = null;
|
$price = null;
|
||||||
//$c = ltrim($code, "0");
|
//$c = ltrim($code, "0");
|
||||||
$json_values = array();
|
$json_values = array();
|
||||||
@@ -153,7 +153,7 @@ class CountryCompareController extends Controller
|
|||||||
$json_values = array(
|
$json_values = array(
|
||||||
'url' => $url_product,
|
'url' => $url_product,
|
||||||
'tag' => null,
|
'tag' => null,
|
||||||
'price' => floatval($price),
|
'salesPrice' => floatval($price),
|
||||||
'country' => $country,
|
'country' => $country,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -164,18 +164,18 @@ class CountryCompareController extends Controller
|
|||||||
{
|
{
|
||||||
//echo "country: " . $country . ", code: " . $code . "<br>";
|
//echo "country: " . $country . ", code: " . $code . "<br>";
|
||||||
//Log::info('{country},{body},{code}',[$country, $body, $code]);
|
//Log::info('{country},{body},{code}',[$country, $body, $code]);
|
||||||
$body = file_get_contents("https://www.ikea.bg/search-results/?query=80366284");
|
//$body = file_get_contents("https://www.ikea.bg/search-results/?query=80366284");
|
||||||
|
|
||||||
$dochtml = new \DOMDocument();
|
$dochtml = new \DOMDocument();
|
||||||
$dochtml->loadHTML($body);
|
@$dochtml->loadHTML($body);
|
||||||
|
|
||||||
$xpath = new \DOMXpath($dochtml);
|
@$xpath = new \DOMXpath($dochtml);
|
||||||
$price = null;
|
$price = null;
|
||||||
$c = ltrim($code, "0");
|
$c = ltrim($code, "0");
|
||||||
$json_values = array();
|
$json_values = array();
|
||||||
|
|
||||||
$price = $xpath->query('//*/div[(@class="yotpo yotpo-main-widget" and @data-product-id="' . $code . '")]/@data-price')[0]->nodeValue;
|
@$price = $xpath->query('//*/div[(@class="yotpo yotpo-main-widget" and @data-product-id="' . $code . '")]/@data-price')[0]->nodeValue;
|
||||||
$url_product = $xpath->query('//*/div[(@class="yotpo yotpo-main-widget" and @data-product-id="' . $code . '")]/@data-url')[0]->nodeValue;
|
@$url_product = $xpath->query('//*/div[(@class="yotpo yotpo-main-widget" and @data-product-id="' . $code . '")]/@data-url')[0]->nodeValue;
|
||||||
|
|
||||||
$price = floatval($price);
|
$price = floatval($price);
|
||||||
|
|
||||||
@@ -183,8 +183,8 @@ class CountryCompareController extends Controller
|
|||||||
$json_values = array(
|
$json_values = array(
|
||||||
'url_product' => $url_product,
|
'url_product' => $url_product,
|
||||||
'tag' => null,
|
'tag' => null,
|
||||||
'price' => floatval($price),
|
'salesPrice' => floatval($price),
|
||||||
'price_eur' => 0
|
'country' => $country,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $json_values;
|
return $json_values;
|
||||||
@@ -195,17 +195,17 @@ class CountryCompareController extends Controller
|
|||||||
//echo "country: " . $country . ", code: " . $code . "<br>";
|
//echo "country: " . $country . ", code: " . $code . "<br>";
|
||||||
|
|
||||||
$dochtml = new \DOMDocument();
|
$dochtml = new \DOMDocument();
|
||||||
@$dochtml->loadHTML('<?xml encoding="UTF-8">' . $body);
|
@$dochtml->loadHTML( $body);
|
||||||
|
|
||||||
$xpath = new \DOMXpath($dochtml);
|
@$xpath = new \DOMXpath($dochtml);
|
||||||
$price = null;
|
$price = null;
|
||||||
$c = ltrim($code, "0");
|
$c = ltrim($code, "0");
|
||||||
$json_values = array();
|
$json_values = array();
|
||||||
|
|
||||||
$price = $xpath->query('//*/div[(@class="itemPriceBox" and @data-item="' . $c . '")]//p[@class="itemNormalPrice display-6"]/span')[0]->nodeValue;
|
@$price = $xpath->query('//*/div[(@class="itemPriceBox" and @data-item="' . $c . '")]//p[@class="itemNormalPrice display-6"]/span')[0]->nodeValue;
|
||||||
|
|
||||||
if (is_null($price) || empty($price)) {
|
if (is_null($price) || empty($price)) {
|
||||||
$price = $xpath->query('//*/div[(@class="itemPriceBox" and @data-item="' . $c . '")]//div[@class="itemBTI display-6"]/span')[0]->nodeValue;
|
@$price = $xpath->query('//*/div[(@class="itemPriceBox" and @data-item="' . $c . '")]//div[@class="itemBTI display-6"]/span')[0]->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($country) {
|
switch ($country) {
|
||||||
@@ -231,7 +231,7 @@ class CountryCompareController extends Controller
|
|||||||
$json_values = array(
|
$json_values = array(
|
||||||
'url' => $url_product,
|
'url' => $url_product,
|
||||||
'tag' => null,
|
'tag' => null,
|
||||||
'price' => $price,
|
'salesPrice' => $price,
|
||||||
'country' => $country,
|
'country' => $country,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -247,21 +247,21 @@ class CountryCompareController extends Controller
|
|||||||
// $res = $client->request('GET', 'https://ikea.is/is/search/?q=80366284');
|
// $res = $client->request('GET', 'https://ikea.is/is/search/?q=80366284');
|
||||||
// $body= $res->getBody()->getContents();
|
// $body= $res->getBody()->getContents();
|
||||||
$dochtml = new \DOMDocument();
|
$dochtml = new \DOMDocument();
|
||||||
@$dochtml->loadHTML('<?xml encoding="UTF-8">' . $body);
|
@$dochtml->loadHTML( $body);
|
||||||
|
|
||||||
$xpath = new \DOMXpath($dochtml);
|
@$xpath = new \DOMXpath($dochtml);
|
||||||
$price = null;
|
$price = null;
|
||||||
$c = ltrim($code, "0");
|
$c = ltrim($code, "0");
|
||||||
$json_values = array();
|
$json_values = array();
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
$price = $xpath->query('//*/div[(@class="itemPriceBox")]//p[@class="itemNormalPrice revamp_price price"]/span/span')[0]->nodeValue;
|
@$price = $xpath->query('//*/div[(@class="itemPriceBox")]//p[@class="itemNormalPrice revamp_price price"]/span/span')[0]->nodeValue;
|
||||||
|
|
||||||
if (is_null($price) || empty($price)) {
|
if (is_null($price) || empty($price)) {
|
||||||
$price = $xpath->query('//*/div[(@class="itemPriceBox")]//p[@class="itemBTI display-6 revamp_price price"]/span/span')[0]->nodeValue;
|
@$price = $xpath->query('//*/div[(@class="itemPriceBox")]//p[@class="itemBTI display-6 revamp_price price"]/span/span')[0]->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$url_product = "https://www.ikea.is" . $xpath->query('/html/head/meta[(@property="og:url")]/@content')[0]->nodeValue;
|
@$url_product = "https://www.ikea.is" . $xpath->query('/html/head/meta[(@property="og:url")]/@content')[0]->nodeValue;
|
||||||
|
|
||||||
//echo "url_product: " . $url_product . "<br>";
|
//echo "url_product: " . $url_product . "<br>";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user