Skip to content

Commit

Permalink
Enhancements:
Browse files Browse the repository at this point in the history
- Remove error class from amazon
- reduce size of docker file

Took 1 hour 44 minutes
  • Loading branch information
Cybrarist committed Oct 31, 2024
1 parent 454fc83 commit 8991b3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM dunglas/frankenphp:latest-builder-php8.3.7-bookworm
FROM dunglas/frankenphp:1.2.5-php8.3.13-bookworm

LABEL authors="Cybrarist"

ENV SERVER_NAME=":80"
ENV FRANKENPHP_CONFIG="worker /app/public/index.php"
ENV FRANKEN_HOST="localhost"

RUN apt update && apt install -y supervisor \
libmcrypt-dev \
RUN apt update && apt install -y supervisor \
libbz2-dev \
libzip-dev \
libmcrypt-dev \
libicu-dev \
gnupg \
ca-certificates \
Expand Down Expand Up @@ -46,7 +46,6 @@ RUN docker-php-ext-install pcntl \
intl \
iconv \
bcmath \
opcache \
calendar \
pdo_mysql \
zip
Expand All @@ -55,7 +54,6 @@ COPY ./docker/base_supervisord.conf /etc/supervisor/conf.d/supervisord.conf

COPY . /app


WORKDIR /app

EXPOSE 80 443 2019 8080
Expand Down
26 changes: 13 additions & 13 deletions app/Helpers/StoresAvailable/Amazon.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function prepare_sections_to_crawl(): void
$this->center_column=$this->xml->xpath("//div[@id='centerCol']")[0];
//get the right column to get the seller and other data
$this->right_column=$this->xml->xpath("//div[@id='desktop_buybox']")[0];
}catch (Error | Exception $exception) {
}catch ( Exception $exception) {
$this->log_error("Crawling Amazon", $exception->getMessage());
}

Expand All @@ -58,14 +58,14 @@ public function get_name(): void
$this->name = explode(":" ,$this->document->getElementsByTagName("title")->item(0)->textContent)[0];
return;
}
catch (Error | Exception $exception){
catch ( Exception $exception){
$this->log_error("Product Name First Method", $exception->getMessage());
}
try {
$this->name = trim($this->center_column->xpath("//span[@id='productname'][1]")[0]
->__toString());
}
catch ( Error | Exception $exception) {
catch ( Exception $exception) {
$this->log_error("Product Name Second Method", $exception->getMessage());
}

Expand All @@ -77,7 +77,7 @@ public function get_image(): void
try {
$this->image = $this->document->getElementById("landingImage")->getAttribute("data-old-hires");
}
catch ( Error | Exception $exception) {
catch ( Exception $exception) {
$this->log_error("Product Image First Method", $exception->getMessage());
}

Expand All @@ -89,7 +89,7 @@ public function get_price(): void
$this->price= (float) Str::replace( Currency::find($this->current_record->currency_id) , "" ,$this->center_column->xpath("(//span[contains(@class, 'apexPriceToPay')])[1]")[0]->span->__toString());
return ;
}
catch ( Error | Exception $exception ) {
catch ( Exception $exception ) {
$this->log_error("Price First Method",$exception->getMessage());
}

Expand All @@ -108,7 +108,7 @@ public function get_price(): void
$this->price= (float)"$whole.$fraction";
return;
}
catch (Error | Exception $exception ) {
catch ( Exception $exception ) {
$this->log_error( "Price Second Method",$exception->getMessage());
}
//method 2 to return the price of the product
Expand All @@ -126,7 +126,7 @@ public function get_price(): void

$this->price= (float)"$whole.$fraction";
}
catch (Error | Exception $exception ) {
catch ( Exception $exception ) {
$this->log_error( "Price Second Method",$exception->getMessage());
}
}
Expand All @@ -142,7 +142,7 @@ public function get_used_price(): void
if ($single_price->{"buyingOptionType"} == "USED")
$this->price_used=$single_price->{'priceAmount'};
}
catch ( Error | Exception $exception )
catch ( Exception $exception )
{
$this->log_error("First Method Used Price",$exception->getMessage());
}
Expand All @@ -166,7 +166,7 @@ public function get_no_of_rates(): void
$ratings=$this->center_column->xpath("//span[@id='acrCustomerReviewText']")[0]->__toString();
$this->no_of_rates= (int) GeneralHelper::get_numbers_only_with_dot($ratings);
}
catch (Error | Exception $exception)
catch ( Exception $exception)
{
$this->log_error("No. Of Rates", $exception->getMessage());
}
Expand All @@ -182,7 +182,7 @@ public function get_rate(): void
$this->center_column->xpath("//div[@id='averageCustomerReviews']//span[@id='acrPopover']//span[@class='a-icon-alt']")[0]->__toString() ,
2)[0];
}
catch (Error | Exception $exception )
catch ( Exception $exception )
{
$this->log_error("The Rate", $exception->getMessage());
}
Expand All @@ -202,7 +202,7 @@ public function get_seller(): void

return;
}
catch (Error | Exception $exception ) {
catch ( Exception $exception ) {
$this->log_error("The Seller First Method", $exception->getMessage() );
}

Expand All @@ -216,7 +216,7 @@ public function get_seller(): void

return;
}
catch (Error | Exception $exception ) {
catch ( Exception $exception ) {
$this->log_error("The Seller Second method", $exception->getMessage() );
}

Expand All @@ -235,7 +235,7 @@ public function get_seller(): void

return;
}
catch (Error | Exception $exception )
catch ( Exception $exception )
{
$this->log_error( "The Seller Third Method" , $exception->getMessage());
$this->seller="";
Expand Down

0 comments on commit 8991b3f

Please sign in to comment.