@@ -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 {
0 commit comments