test for nuc

This commit is contained in:
2024-02-10 13:49:36 +01:00
parent bc7f73c3a0
commit e91f39c9e5
4 changed files with 27 additions and 26 deletions

View File

@@ -20,6 +20,10 @@ tasks:
cmds: cmds:
- vendor/bin/dep deploy web01.ttx.sk - vendor/bin/dep deploy web01.ttx.sk
- vendor/bin/dep build web01.ttx.sk - vendor/bin/dep build web01.ttx.sk
nuc:
cmds:
- vendor/bin/dep deploy nuc.bh.ttx.sk
- vendor/bin/dep build nuc.bh.ttx.sk
ssh: ssh:
cmds: cmds:
- vendor/bin/dep ssh - vendor/bin/dep ssh

View File

@@ -43,8 +43,8 @@ class CountryCompareController extends Controller
{ {
$requests = Http::pool(fn (Pool $pool) => [ $requests = Http::pool(fn (Pool $pool) => [
$this->countries->each(function ($country) use ($pool, $ta_code) { $this->countries->each(function ($country) use ($pool, $ta_code) {
Log::info('Getting page {url}', [ 'url' => $country->search_url . $ta_code ] ); Log::info('Getting page {url}', [ 'url' => $country->search_url . $ta_code[0] ] );
return $pool->as($country->country_code)->get($country->search_url . $ta_code); return $pool->as($country->country_code)->get($country->search_url . $ta_code[0] );
}) })
]); ]);
return $requests; return $requests;
@@ -68,7 +68,9 @@ class CountryCompareController extends Controller
if ($responses[$country] instanceof \Illuminate\Http\Client\Response && $responses[$country]->ok()) { if ($responses[$country] instanceof \Illuminate\Http\Client\Response && $responses[$country]->ok()) {
$response = $responses[$country]->body(); // dd($responses);
$response = (string) $responses[$country]->body();
//dd($response)
switch ($country) { switch ($country) {
case "BG": case "BG":
case "BY": case "BY":
@@ -104,7 +106,6 @@ class CountryCompareController extends Controller
public function parseJson($json_raw, $country) public function parseJson($json_raw, $country)
{ {
try {
$json_values = array(); $json_values = array();
$json_decoded = json_decode($json_raw, true); $json_decoded = json_decode($json_raw, true);
@@ -128,9 +129,6 @@ class CountryCompareController extends Controller
); );
break; break;
} }
} catch (\Exception $e) {
return [];
}
return $json_values; return $json_values;
} }
@@ -165,29 +163,28 @@ class CountryCompareController extends Controller
public function parseJson_CY_GR_BG($code, $body , $country) public function parseJson_CY_GR_BG($code, $body , $country)
{ {
//echo "country: " . $country . ", code: " . $code . "<br>"; //echo "country: " . $country . ", code: " . $code . "<br>";
//Log::info('{country},{body},{code}',[$country, $body, $code]);
$body = file_get_contents("https://www.ikea.bg/search-results/?query=80366284");
$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 {
$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;
} catch (\Exception $e) {
return [];
}
$price = floatval($price); $price = floatval($price);
$json_values = array( $json_values = array(
'url' => $url_product, 'url_product' => $url_product,
'tag' => null, 'tag' => null,
'price' => floatval($price), 'price' => floatval($price),
'country' => $country, 'price_eur' => 0
); );
return $json_values; return $json_values;
@@ -205,7 +202,6 @@ class CountryCompareController extends Controller
$c = ltrim($code, "0"); $c = ltrim($code, "0");
$json_values = array(); $json_values = array();
try {
$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)) {
@@ -225,9 +221,6 @@ class CountryCompareController extends Controller
default: default:
$url_product = null; $url_product = null;
} }
} catch (\Exception $e) {
return [];
}
if (is_null($price) || empty($price)) { if (is_null($price) || empty($price)) {
$url_product = null; $url_product = null;
@@ -249,6 +242,10 @@ class CountryCompareController extends Controller
{ {
//echo "country: " . $country . ", code: " . $code . "<br>"; //echo "country: " . $country . ", code: " . $code . "<br>";
//$body = file_get_contents("https://ikea.is/is/search/?q=80366284");
// $client = new \GuzzleHttp\Client();
// $res = $client->request('GET', 'https://ikea.is/is/search/?q=80366284');
// $body= $res->getBody()->getContents();
$dochtml = new \DOMDocument(); $dochtml = new \DOMDocument();
@$dochtml->loadHTML('<?xml encoding="UTF-8">' . $body); @$dochtml->loadHTML('<?xml encoding="UTF-8">' . $body);
@@ -280,7 +277,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,
); );

View File

@@ -49,7 +49,7 @@ class ProductsCompareController extends Controller
if ($online == true) { if ($online == true) {
Log::info("ONLINE {codes} {countries}", ["codes" => $codes, "countries" => $countries, "online" => $online]); Log::info("ONLINE {codes} {countries}", ["codes" => $codes, "countries" => $countries, "online" => $online]);
$products = $this->countryCompareController->compare($countries, $cHash, $aCodes); $products = $this->countryCompareController->compare($countries, $cHash, $codes);
} else { } else {
$products = IkeaProducts::whereIn("code", $aCodes); $products = IkeaProducts::whereIn("code", $aCodes);
if (count($countries)) $products->whereIn("country", $countries); if (count($countries)) $products->whereIn("country", $countries);

View File

@@ -18,7 +18,7 @@
"postcss": "^8.4.14", "postcss": "^8.4.14",
"tailwindcss": "^3.1.0", "tailwindcss": "^3.1.0",
"vite": "^2.9.11", "vite": "^2.9.11",
"vue": "^3.2.31" "vue": "^3.4.15"
}, },
"dependencies": { "dependencies": {
"@vueform/multiselect": "^2.5.1", "@vueform/multiselect": "^2.5.1",