You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more information, please visit [https://webscraping.ai](https://webscraping.ai)
10
11
11
12
## Requirements.
12
13
13
-
Python 3.7+
14
+
Python 3.8+
14
15
15
16
## Installation & Usage
16
17
### pip install
@@ -51,7 +52,6 @@ Please follow the [installation procedure](#installation--usage) and then run th
51
52
52
53
```python
53
54
54
-
import time
55
55
import webscraping_ai
56
56
from webscraping_ai.rest import ApiException
57
57
from pprint import pprint
@@ -79,28 +79,27 @@ with webscraping_ai.ApiClient(configuration) as api_client:
79
79
# Create an instance of the API class
80
80
api_instance = webscraping_ai.AIApi(api_client)
81
81
url ='https://example.com'# str | URL of the target page.
82
-
question ='What is the summary of this page content?'# str | Question or instructions to ask the LLM model about the target page. (optional)
83
-
context_limit =4000# int | Maximum number of tokens to use as context for the LLM model (4000 by default). (optional) (default to 4000)
84
-
response_tokens =100# int | Maximum number of tokens to return in the LLM model response. The total context size (context_limit) includes the question, the target page content and the response, so this parameter reserves tokens for the response (see also on_context_limit). (optional) (default to 100)
85
-
on_context_limit ='error'# str | What to do if the context_limit parameter is exceeded (truncate by default). The context is exceeded when the target page content is too long. (optional) (default to 'error')
82
+
fields = {'key': '{\"title\":\"Main product title\",\"price\":\"Current product price\",\"description\":\"Full product description\"}'} # Dict[str, str] | Object describing fields to extract from the page and their descriptions
86
83
headers = {'key': '{\"Cookie\":\"session=some_id\"}'} # Dict[str, str] | HTTP headers to pass to the target page. Can be specified either via a nested query parameter (...&headers[One]=value1&headers=[Another]=value2) or as a JSON encoded object (...&headers={\"One\": \"value1\", \"Another\": \"value2\"}). (optional)
87
84
timeout =10000# int | Maximum web page retrieval time in ms. Increase it in case of timeout errors (10000 by default, maximum is 30000). (optional) (default to 10000)
88
85
js =True# bool | Execute on-page JavaScript using a headless browser (true by default). (optional) (default to True)
89
86
js_timeout =2000# int | Maximum JavaScript rendering time in ms. Increase it in case if you see a loading indicator instead of data on the target page. (optional) (default to 2000)
90
-
proxy ='datacenter'# str | Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default). Note that residential proxy requests are more expensive than datacenter, see the pricing page for details. (optional) (default to 'datacenter')
91
-
country ='us'# str | Country of the proxy to use (US by default). Only available on Startup and Custom plans. (optional) (default to 'us')
92
-
device ='desktop'# str | Type of device emulation. (optional) (default to 'desktop')
87
+
wait_for ='wait_for_example'# str | CSS selector to wait for before returning the page content. Useful for pages with dynamic content loading. Overrides js_timeout. (optional)
88
+
proxy = datacenter # str | Type of proxy, use residential proxies if your site restricts traffic from datacenters (datacenter by default). Note that residential proxy requests are more expensive than datacenter, see the pricing page for details. (optional) (default to datacenter)
89
+
country = us # str | Country of the proxy to use (US by default). (optional) (default to us)
90
+
custom_proxy ='custom_proxy_example'# str | Your own proxy URL to use instead of our built-in proxy pool in \"http://user:password@host:port\" format (<a target=\"_blank\" href=\"https://webscraping.ai/proxies/smartproxy\">Smartproxy</a> for example). (optional)
91
+
device = desktop # str | Type of device emulation. (optional) (default to desktop)
93
92
error_on_404 =False# bool | Return error on 404 HTTP status on the target page (false by default). (optional) (default to False)
94
93
error_on_redirect =False# bool | Return error on redirect on the target page (false by default). (optional) (default to False)
95
-
js_script ='document.querySelector('button').click();'# str | Custom JavaScript code to execute on the target page. (optional)
94
+
js_script ='document.querySelector(\'button\').click();'# str | Custom JavaScript code to execute on the target page. (optional)
96
95
97
96
try:
98
-
#Get an answer to a question about a given web page
0 commit comments