Skip to content

Commit 7bdeb21

Browse files
committed
add new aiQuery method to LaravelScrapingBee class & remove timeout parameter from LaravelScrapingBeeGoogleSearch class since no where in the code use it
1 parent 79f94d1 commit 7bdeb21

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/LaravelScrapingBee.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,17 @@ private function request(string $method, string $url, array $data = [], string $
6969
return $response;
7070
}
7171

72+
/**
73+
* @throws ConnectionException
74+
*/
7275
public function get(string $url): Response
7376
{
7477
return $this->request('GET', $url);
7578
}
7679

80+
/**
81+
* @throws ConnectionException
82+
*/
7783
public function post(string $url, array $data = [], string $postContentType = 'application/x-www-form-urlencoded; charset=utf-8'): Response
7884
{
7985
return $this->request('POST', $url, $data, $postContentType);
@@ -142,6 +148,7 @@ public function device(string $device): self
142148
/**
143149
* https://www.scrapingbee.com/documentation/#json_css
144150
* https://www.scrapingbee.com/documentation/data-extraction/
151+
* @throws \JsonException
145152
*/
146153
public function extractDataFromCssRules(array $cssRules): self
147154
{
@@ -150,6 +157,23 @@ public function extractDataFromCssRules(array $cssRules): self
150157
return $this;
151158
}
152159

160+
/*
161+
* https://www.scrapingbee.com/documentation/#ai_query
162+
* https://www.scrapingbee.com/documentation/#ai_selector
163+
*
164+
* There is no aiSelector() method since it need to be used with aiQuery
165+
*/
166+
public function aiQuery(string $query, ?string $selector = null): self
167+
{
168+
$this->params['ai_query'] = $query;
169+
170+
if ($selector !== null) {
171+
$this->params['ai_selector'] = $selector;
172+
}
173+
174+
return $this;
175+
}
176+
153177
/**
154178
* https://www.scrapingbee.com/documentation/#json_response
155179
*/
@@ -387,8 +411,7 @@ public function output(string $output): self
387411
/*
388412
* This is for the situation if our API did not catch up and you want to add a new parameter
389413
* that Scrapingbee supports
390-
* like ->setParam('stealth_proxy', true) for example
391-
* stealth proxy feature is in beta and hence I have not add a dedicated method to support it yet
414+
* like ->setParam('new_beta_feature', true) for example
392415
*/
393416
public function setParam(string $key, mixed $value): self
394417
{

src/LaravelScrapingBeeGoogleSearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function make(#[\SensitiveParameter] ?string $apiKey = null): self
2020
return new self($apiKey);
2121
}
2222

23-
public function __construct(#[\SensitiveParameter] ?string $apiKey = null, ?int $timeout = null)
23+
public function __construct(#[\SensitiveParameter] ?string $apiKey = null)
2424
{
2525
// If somebody pass '' into the constructor, we should use '' as the api key
2626
// even if it doesn't make sense.

0 commit comments

Comments
 (0)