Skip to content

Commit

Permalink
Added support for captcha checking
Browse files Browse the repository at this point in the history
  • Loading branch information
tim hall committed Mar 31, 2021
1 parent ff60600 commit d96ee5a
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":9009:{a:2:{s:7:"defects";a:19:{s:85:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_response";i:4;s:96:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_image_response";i:4;s:104:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_early_reviewer_rewards";i:4;s:76:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_use_dom_html";i:4;s:85:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_bug";i:3;s:96:"EolabsIo\AmazonMwsClient\Tests\RequestReportResponseParserTest::it_can_parse_order_list_response";i:4;s:103:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListResponseParserTest::it_can_parse_order_list_response";i:3;s:108:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListByNextTokenResponseParserTest::it_can_get_result_accessor";i:3;s:114:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListByNextTokenResponseParserTest::it_can_parse_order_list_response";i:4;s:98:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestCountResponseParserTest::it_can_get_result_accessor";i:3;s:114:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestCountResponseParserTest::it_can_parse_report_request_count_response";i:3;s:113:"EolabsIo\AmazonMwsClient\Tests\CancelReportRequestsResponseParserTest::it_can_parse_report_request_count_response";i:3;s:96:"EolabsIo\AmazonMwsClient\Tests\GetReportListResponseParserTest::it_can_parse_order_list_response";i:3;s:95:"EolabsIo\AmazonMwsClient\Tests\GetReportResponseParserTest::it_can_parse_review_rating_response";i:4;s:90:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_get_result_accessor";i:4;s:96:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_parse_order_list_response";i:3;s:112:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_asin_response";i:3;s:118:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_sku_single_response";i:3;s:113:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_parse_product_categories_for_asin_response";i:4;}s:5:"times";a:56:{s:122:"EolabsIo\AmazonMwsClient\Tests\AmazonMwsResponseParserTest::it_throws_an_exception_if_an_invalid_response_type_is_provided";d:0.038;s:83:"EolabsIo\AmazonMwsClient\Tests\ErrorResponseParserTest::it_can_parse_error_response";d:0.002;s:95:"EolabsIo\AmazonMwsClient\Tests\GetMatchingProductResponseParserTest::it_can_get_result_accessor";d:0.002;s:111:"EolabsIo\AmazonMwsClient\Tests\GetMatchingProductResponseParserTest::it_can_parse_get_matching_product_response";d:0.002;s:112:"EolabsIo\AmazonMwsClient\Tests\GetMatchingProductResponseParserTest::it_can_parse_get_matching_products_response";d:0.003;s:119:"EolabsIo\AmazonMwsClient\Tests\InventoryServiceStatusResponseParserTest::it_can_parse_inventory_service_status_response";d:0.002;s:112:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventGroupsByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.002;s:143:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventGroupsByNextTokenResponseParserTest::it_can_parse_list_inventory_supply_by_next_token_response";d:0.002;s:101:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventGroupsResponseParserTest::it_can_get_result_accessor";d:0.002;s:107:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventGroupsResponseParserTest::it_can_parse_order_list_response";d:0.003;s:107:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventsByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.003;s:138:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventsByNextTokenResponseParserTest::it_can_parse_list_financial_events_by_next_token_response";d:0.003;s:96:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventsResponseParserTest::it_can_get_result_accessor";d:0.01;s:113:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventsResponseParserTest::it_can_parse_financial_events_list_response";d:0.009;s:107:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.003;s:138:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyByNextTokenResponseParserTest::it_can_parse_list_inventory_supply_by_next_token_response";d:0.003;s:96:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyResponseParserTest::it_can_get_result_accessor";d:0.002;s:113:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyResponseParserTest::it_can_parse_list_inventory_supply_response";d:0.002;s:124:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyResponseParserTest::it_can_parse_list_inventory_supply_with_token_response";d:0.002;s:106:"EolabsIo\AmazonMwsClient\Tests\ListMarketplaceParticipationsResponseParserTest::it_can_get_result_accessor";d:0.002;s:142:"EolabsIo\AmazonMwsClient\Tests\ListMarketplaceParticipationsResponseParserTest::it_can_parse_list_marketplace_participations_response_response";d:0.003;s:102:"EolabsIo\AmazonMwsClient\Tests\ListOrderItemsByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.003;s:123:"EolabsIo\AmazonMwsClient\Tests\ListOrderItemsByNextTokenResponseParserTest::it_can_parse_list_orders_by_next_token_response";d:0.002;s:91:"EolabsIo\AmazonMwsClient\Tests\ListOrderItemsResponseParserTest::it_can_get_result_accessor";d:0.002;s:97:"EolabsIo\AmazonMwsClient\Tests\ListOrderItemsResponseParserTest::it_can_parse_order_item_response";d:0.002;s:98:"EolabsIo\AmazonMwsClient\Tests\ListOrdersByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.002;s:119:"EolabsIo\AmazonMwsClient\Tests\ListOrdersByNextTokenResponseParserTest::it_can_parse_list_orders_by_next_token_response";d:0.003;s:87:"EolabsIo\AmazonMwsClient\Tests\ListOrdersResponseParserTest::it_can_get_result_accessor";d:0.003;s:93:"EolabsIo\AmazonMwsClient\Tests\ListOrdersResponseParserTest::it_can_parse_order_list_response";d:0.003;s:110:"EolabsIo\AmazonMwsClient\Tests\ListOrdersResponseParserTest::it_can_parse_order_list_removes_elements_response";d:0.003;s:85:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_response";d:0.41;s:98:"EolabsIo\AmazonMwsClient\Tests\ReviewRatingResponseParserTest::it_can_parse_review_rating_response";d:0.175;s:96:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_image_response";d:0.024;s:104:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_early_reviewer_rewards";d:0.385;s:76:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_use_dom_html";d:0.051;s:85:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_bug";d:0.035;s:90:"EolabsIo\AmazonMwsClient\Tests\RequestReportResponseParserTest::it_can_get_result_accessor";d:0.002;s:96:"EolabsIo\AmazonMwsClient\Tests\RequestReportResponseParserTest::it_can_parse_order_list_response";d:0.002;s:97:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListResponseParserTest::it_can_get_result_accessor";d:0.002;s:103:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListResponseParserTest::it_can_parse_order_list_response";d:0.003;s:108:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.002;s:114:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListByNextTokenResponseParserTest::it_can_parse_order_list_response";d:0.002;s:98:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestCountResponseParserTest::it_can_get_result_accessor";d:0.002;s:114:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestCountResponseParserTest::it_can_parse_report_request_count_response";d:0.002;s:97:"EolabsIo\AmazonMwsClient\Tests\CancelReportRequestsResponseParserTest::it_can_get_result_accessor";d:0.003;s:113:"EolabsIo\AmazonMwsClient\Tests\CancelReportRequestsResponseParserTest::it_can_parse_report_request_count_response";d:0.002;s:90:"EolabsIo\AmazonMwsClient\Tests\GetReportListResponseParserTest::it_can_get_result_accessor";d:0.003;s:96:"EolabsIo\AmazonMwsClient\Tests\GetReportListResponseParserTest::it_can_parse_order_list_response";d:0.003;s:95:"EolabsIo\AmazonMwsClient\Tests\GetReportResponseParserTest::it_can_parse_review_rating_response";d:0.002;s:90:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_get_result_accessor";d:0.002;s:96:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_parse_order_list_response";d:0.003;s:89:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_get_result_accessor";d:0.002;s:112:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_asin_response";d:0.003;s:111:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_sku_response";d:0.002;s:118:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_sku_single_response";d:0.002;s:113:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_parse_product_categories_for_asin_response";d:0.003;}}}
C:37:"PHPUnit\Runner\DefaultTestResultCache":9195:{a:2:{s:7:"defects";a:20:{s:85:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_response";i:4;s:96:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_image_response";i:4;s:104:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_early_reviewer_rewards";i:4;s:76:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_use_dom_html";i:4;s:85:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_bug";i:4;s:96:"EolabsIo\AmazonMwsClient\Tests\RequestReportResponseParserTest::it_can_parse_order_list_response";i:4;s:103:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListResponseParserTest::it_can_parse_order_list_response";i:3;s:108:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListByNextTokenResponseParserTest::it_can_get_result_accessor";i:3;s:114:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListByNextTokenResponseParserTest::it_can_parse_order_list_response";i:4;s:98:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestCountResponseParserTest::it_can_get_result_accessor";i:3;s:114:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestCountResponseParserTest::it_can_parse_report_request_count_response";i:3;s:113:"EolabsIo\AmazonMwsClient\Tests\CancelReportRequestsResponseParserTest::it_can_parse_report_request_count_response";i:3;s:96:"EolabsIo\AmazonMwsClient\Tests\GetReportListResponseParserTest::it_can_parse_order_list_response";i:3;s:95:"EolabsIo\AmazonMwsClient\Tests\GetReportResponseParserTest::it_can_parse_review_rating_response";i:4;s:90:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_get_result_accessor";i:4;s:96:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_parse_order_list_response";i:3;s:112:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_asin_response";i:3;s:118:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_sku_single_response";i:3;s:113:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_parse_product_categories_for_asin_response";i:4;s:78:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_detect_captcha";i:4;}s:5:"times";a:57:{s:122:"EolabsIo\AmazonMwsClient\Tests\AmazonMwsResponseParserTest::it_throws_an_exception_if_an_invalid_response_type_is_provided";d:0.039;s:83:"EolabsIo\AmazonMwsClient\Tests\ErrorResponseParserTest::it_can_parse_error_response";d:0.005;s:95:"EolabsIo\AmazonMwsClient\Tests\GetMatchingProductResponseParserTest::it_can_get_result_accessor";d:0.006;s:111:"EolabsIo\AmazonMwsClient\Tests\GetMatchingProductResponseParserTest::it_can_parse_get_matching_product_response";d:0.004;s:112:"EolabsIo\AmazonMwsClient\Tests\GetMatchingProductResponseParserTest::it_can_parse_get_matching_products_response";d:0.006;s:119:"EolabsIo\AmazonMwsClient\Tests\InventoryServiceStatusResponseParserTest::it_can_parse_inventory_service_status_response";d:0.005;s:112:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventGroupsByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.006;s:143:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventGroupsByNextTokenResponseParserTest::it_can_parse_list_inventory_supply_by_next_token_response";d:0.004;s:101:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventGroupsResponseParserTest::it_can_get_result_accessor";d:0.006;s:107:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventGroupsResponseParserTest::it_can_parse_order_list_response";d:0.004;s:107:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventsByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.008;s:138:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventsByNextTokenResponseParserTest::it_can_parse_list_financial_events_by_next_token_response";d:0.004;s:96:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventsResponseParserTest::it_can_get_result_accessor";d:0.015;s:113:"EolabsIo\AmazonMwsClient\Tests\ListFinancialEventsResponseParserTest::it_can_parse_financial_events_list_response";d:0.011;s:107:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.008;s:138:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyByNextTokenResponseParserTest::it_can_parse_list_inventory_supply_by_next_token_response";d:0.004;s:96:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyResponseParserTest::it_can_get_result_accessor";d:0.006;s:113:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyResponseParserTest::it_can_parse_list_inventory_supply_response";d:0.003;s:124:"EolabsIo\AmazonMwsClient\Tests\ListInventorySupplyResponseParserTest::it_can_parse_list_inventory_supply_with_token_response";d:0.003;s:106:"EolabsIo\AmazonMwsClient\Tests\ListMarketplaceParticipationsResponseParserTest::it_can_get_result_accessor";d:0.004;s:142:"EolabsIo\AmazonMwsClient\Tests\ListMarketplaceParticipationsResponseParserTest::it_can_parse_list_marketplace_participations_response_response";d:0.003;s:102:"EolabsIo\AmazonMwsClient\Tests\ListOrderItemsByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.004;s:123:"EolabsIo\AmazonMwsClient\Tests\ListOrderItemsByNextTokenResponseParserTest::it_can_parse_list_orders_by_next_token_response";d:0.003;s:91:"EolabsIo\AmazonMwsClient\Tests\ListOrderItemsResponseParserTest::it_can_get_result_accessor";d:0.003;s:97:"EolabsIo\AmazonMwsClient\Tests\ListOrderItemsResponseParserTest::it_can_parse_order_item_response";d:0.003;s:98:"EolabsIo\AmazonMwsClient\Tests\ListOrdersByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.005;s:119:"EolabsIo\AmazonMwsClient\Tests\ListOrdersByNextTokenResponseParserTest::it_can_parse_list_orders_by_next_token_response";d:0.003;s:87:"EolabsIo\AmazonMwsClient\Tests\ListOrdersResponseParserTest::it_can_get_result_accessor";d:0.007;s:93:"EolabsIo\AmazonMwsClient\Tests\ListOrdersResponseParserTest::it_can_parse_order_list_response";d:0.004;s:110:"EolabsIo\AmazonMwsClient\Tests\ListOrdersResponseParserTest::it_can_parse_order_list_removes_elements_response";d:0.003;s:85:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_response";d:0.417;s:98:"EolabsIo\AmazonMwsClient\Tests\ReviewRatingResponseParserTest::it_can_parse_review_rating_response";d:0.188;s:96:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_image_response";d:0.022;s:104:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_early_reviewer_rewards";d:0.391;s:76:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_use_dom_html";d:0.051;s:85:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_parse_review_with_bug";d:0.026;s:90:"EolabsIo\AmazonMwsClient\Tests\RequestReportResponseParserTest::it_can_get_result_accessor";d:0.006;s:96:"EolabsIo\AmazonMwsClient\Tests\RequestReportResponseParserTest::it_can_parse_order_list_response";d:0.004;s:97:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListResponseParserTest::it_can_get_result_accessor";d:0.004;s:103:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListResponseParserTest::it_can_parse_order_list_response";d:0.003;s:108:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListByNextTokenResponseParserTest::it_can_get_result_accessor";d:0.006;s:114:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestListByNextTokenResponseParserTest::it_can_parse_order_list_response";d:0.003;s:98:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestCountResponseParserTest::it_can_get_result_accessor";d:0.006;s:114:"EolabsIo\AmazonMwsClient\Tests\GetReportRequestCountResponseParserTest::it_can_parse_report_request_count_response";d:0.004;s:97:"EolabsIo\AmazonMwsClient\Tests\CancelReportRequestsResponseParserTest::it_can_get_result_accessor";d:0.006;s:113:"EolabsIo\AmazonMwsClient\Tests\CancelReportRequestsResponseParserTest::it_can_parse_report_request_count_response";d:0.004;s:90:"EolabsIo\AmazonMwsClient\Tests\GetReportListResponseParserTest::it_can_get_result_accessor";d:0.005;s:96:"EolabsIo\AmazonMwsClient\Tests\GetReportListResponseParserTest::it_can_parse_order_list_response";d:0.003;s:95:"EolabsIo\AmazonMwsClient\Tests\GetReportResponseParserTest::it_can_parse_review_rating_response";d:0.008;s:90:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_get_result_accessor";d:0.007;s:96:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_parse_order_list_response";d:0.003;s:89:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_get_result_accessor";d:0.005;s:112:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_asin_response";d:0.003;s:111:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_sku_response";d:0.004;s:118:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForSKUTest::it_can_parse_product_categories_for_sku_single_response";d:0.005;s:113:"EolabsIo\AmazonMwsClient\Tests\GetProductCategoriesForASINTest::it_can_parse_product_categories_for_asin_response";d:0.004;s:78:"EolabsIo\AmazonMwsClient\Tests\ReviewResponseParserTest::it_can_detect_captcha";d:0.005;}}}
17 changes: 14 additions & 3 deletions src/Parsers/ReviewResponseParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public function handle(Crawler $domCrawler): Collection
return collect()
->merge($this->getAverageStarsRating($domCrawler))
->merge($this->getNumberOfRatingsAndReviews($domCrawler))
->merge($this->getReviews($domCrawler));
->merge($this->getReviews($domCrawler))
->merge($this->checkForCaptcha($domCrawler));
}

public function getAverageStarsRating(Crawler $domCrawler): Collection
Expand All @@ -31,8 +32,11 @@ public function getNumberOfRatingsAndReviews(Crawler $domCrawler): Collection
{
$filterInfoSection = $domCrawler->filter('div[data-hook="cr-filter-info-review-rating-count"]')->text('');
$ratingsAndReviews = Str::of($filterInfoSection)->trim()->explode('|');
$numberOfRatings = Str::of($ratingsAndReviews[0])->trim()->explode(' ')->first();
$numberOfReviews = Str::of($ratingsAndReviews[1])->trim()->explode(' ')->first();

$ratings = data_get($ratingsAndReviews, 0, '');
$reviews = data_get($ratingsAndReviews, 1, '');
$numberOfRatings = Str::of($ratings)->trim()->explode(' ')->first();
$numberOfReviews = Str::of($reviews)->trim()->explode(' ')->first();

return collect(['numberOfReviews' => intval($numberOfReviews), 'numberOfRatings' => intval($numberOfRatings)]);
}
Expand Down Expand Up @@ -145,4 +149,11 @@ public function getImages(Crawler $review): array
return $reviewImage->attr('src');
});
}

public function checkForCaptcha(Crawler $domCrawler): Collection
{
$hasCaptcha = $domCrawler->filter('form[action="/errors/validateCaptcha"]')->matches('form');

return collect(['hasCaptcha' => $hasCaptcha]);
}
}
Loading

0 comments on commit d96ee5a

Please sign in to comment.