diff --git a/Taskfile.yml b/Taskfile.yml
index d814773..b3cefae 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -20,6 +20,10 @@ tasks:
cmds:
- vendor/bin/dep deploy 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:
cmds:
- vendor/bin/dep ssh
diff --git a/app/Http/Controllers/CountryCompareController.php b/app/Http/Controllers/CountryCompareController.php
index 850a756..a538bed 100644
--- a/app/Http/Controllers/CountryCompareController.php
+++ b/app/Http/Controllers/CountryCompareController.php
@@ -43,8 +43,8 @@ class CountryCompareController extends Controller
{
$requests = Http::pool(fn (Pool $pool) => [
$this->countries->each(function ($country) use ($pool, $ta_code) {
- Log::info('Getting page {url}', [ 'url' => $country->search_url . $ta_code ] );
- return $pool->as($country->country_code)->get($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[0] );
})
]);
return $requests;
@@ -68,7 +68,9 @@ class CountryCompareController extends Controller
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) {
case "BG":
case "BY":
@@ -76,7 +78,7 @@ class CountryCompareController extends Controller
$prices[$country] = $this->parseJson_CY_GR_BG($code, (string) $response, $country);
break;
case "IS":
- $prices[$country] = $this->parseJson_IS($code, (string) $response, $country);
+ $prices[$country] = $this->parseJson_IS($code,(string) $response, $country);
break;
case "TR":
$prices[$country] = $this->parseJson_TR((string) $response, $country);
@@ -104,7 +106,6 @@ class CountryCompareController extends Controller
public function parseJson($json_raw, $country)
{
- try {
$json_values = array();
$json_decoded = json_decode($json_raw, true);
@@ -128,9 +129,6 @@ class CountryCompareController extends Controller
);
break;
}
-} catch (\Exception $e) {
- return [];
-}
return $json_values;
}
@@ -165,29 +163,28 @@ class CountryCompareController extends Controller
public function parseJson_CY_GR_BG($code, $body , $country)
{
//echo "country: " . $country . ", code: " . $code . "
";
+ //Log::info('{country},{body},{code}',[$country, $body, $code]);
+ $body = file_get_contents("https://www.ikea.bg/search-results/?query=80366284");
$dochtml = new \DOMDocument();
- @$dochtml->loadHTML('' . $body);
+ $dochtml->loadHTML($body);
$xpath = new \DOMXpath($dochtml);
$price = null;
$c = ltrim($code, "0");
$json_values = array();
- try {
- $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;
- } catch (\Exception $e) {
- return [];
- }
+ $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;
+
$price = floatval($price);
$json_values = array(
- 'url' => $url_product,
- 'tag' => null,
- 'price' => floatval($price),
- 'country' => $country,
+ 'url_product' => $url_product,
+ 'tag' => null,
+ 'price' => floatval($price),
+ 'price_eur' => 0
);
return $json_values;
@@ -205,7 +202,6 @@ class CountryCompareController extends Controller
$c = ltrim($code, "0");
$json_values = array();
- try {
$price = $xpath->query('//*/div[(@class="itemPriceBox" and @data-item="' . $c . '")]//p[@class="itemNormalPrice display-6"]/span')[0]->nodeValue;
if (is_null($price) || empty($price)) {
@@ -225,9 +221,6 @@ class CountryCompareController extends Controller
default:
$url_product = null;
}
- } catch (\Exception $e) {
- return [];
- }
if (is_null($price) || empty($price)) {
$url_product = null;
@@ -249,6 +242,10 @@ class CountryCompareController extends Controller
{
//echo "country: " . $country . ", code: " . $code . "
";
+ //$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->loadHTML('' . $body);
@@ -280,7 +277,7 @@ class CountryCompareController extends Controller
$json_values = array(
'url' => $url_product,
'tag' => null,
- 'price' => $price,
+ 'salesPrice' => $price,
'country' => $country,
);
diff --git a/app/Http/Controllers/ProductsCompareController.php b/app/Http/Controllers/ProductsCompareController.php
index 7783456..cb23096 100644
--- a/app/Http/Controllers/ProductsCompareController.php
+++ b/app/Http/Controllers/ProductsCompareController.php
@@ -49,7 +49,7 @@ class ProductsCompareController extends Controller
if ($online == true) {
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 {
$products = IkeaProducts::whereIn("code", $aCodes);
if (count($countries)) $products->whereIn("country", $countries);
diff --git a/package.json b/package.json
index 5f41248..ab333db 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"postcss": "^8.4.14",
"tailwindcss": "^3.1.0",
"vite": "^2.9.11",
- "vue": "^3.2.31"
+ "vue": "^3.4.15"
},
"dependencies": {
"@vueform/multiselect": "^2.5.1",