diff --git a/src/LaravelScrapingBee.php b/src/LaravelScrapingBee.php index 3b3c80f..54c36d3 100644 --- a/src/LaravelScrapingBee.php +++ b/src/LaravelScrapingBee.php @@ -69,11 +69,17 @@ private function request(string $method, string $url, array $data = [], string $ return $response; } + /** + * @throws ConnectionException + */ public function get(string $url): Response { return $this->request('GET', $url); } + /** + * @throws ConnectionException + */ public function post(string $url, array $data = [], string $postContentType = 'application/x-www-form-urlencoded; charset=utf-8'): Response { return $this->request('POST', $url, $data, $postContentType); @@ -142,6 +148,7 @@ public function device(string $device): self /** * https://www.scrapingbee.com/documentation/#json_css * https://www.scrapingbee.com/documentation/data-extraction/ + * @throws \JsonException */ public function extractDataFromCssRules(array $cssRules): self { @@ -150,6 +157,23 @@ public function extractDataFromCssRules(array $cssRules): self return $this; } + /* + * https://www.scrapingbee.com/documentation/#ai_query + * https://www.scrapingbee.com/documentation/#ai_selector + * + * There is no aiSelector() method since it need to be used with aiQuery + */ + public function aiQuery(string $query, ?string $selector = null): self + { + $this->params['ai_query'] = $query; + + if ($selector !== null) { + $this->params['ai_selector'] = $selector; + } + + return $this; + } + /** * https://www.scrapingbee.com/documentation/#json_response */ @@ -387,8 +411,7 @@ public function output(string $output): self /* * This is for the situation if our API did not catch up and you want to add a new parameter * that Scrapingbee supports - * like ->setParam('stealth_proxy', true) for example - * stealth proxy feature is in beta and hence I have not add a dedicated method to support it yet + * like ->setParam('new_beta_feature', true) for example */ public function setParam(string $key, mixed $value): self { diff --git a/src/LaravelScrapingBeeGoogleSearch.php b/src/LaravelScrapingBeeGoogleSearch.php index cf87c86..4ac0f87 100644 --- a/src/LaravelScrapingBeeGoogleSearch.php +++ b/src/LaravelScrapingBeeGoogleSearch.php @@ -20,7 +20,7 @@ public static function make(#[\SensitiveParameter] ?string $apiKey = null): self return new self($apiKey); } - public function __construct(#[\SensitiveParameter] ?string $apiKey = null, ?int $timeout = null) + public function __construct(#[\SensitiveParameter] ?string $apiKey = null) { // If somebody pass '' into the constructor, we should use '' as the api key // even if it doesn't make sense.