@@ -28,7 +28,7 @@ monitor = client.monitor.create(
2828 name = " Price Tracker" ,
2929 url = " https://example.com/products" ,
3030 prompt = " Extract current product prices" ,
31- cron = " 0 9 * * *" , # Daily at 9 AM
31+ interval = " 0 9 * * *" , # Daily at 9 AM
3232)
3333print (" Monitor created:" , monitor)
3434```
@@ -42,7 +42,7 @@ const monitor = await sgai.monitor.create({
4242 name: ' Price Tracker' ,
4343 url: ' https://example.com/products' ,
4444 prompt: ' Extract current product prices' ,
45- cron : ' 0 9 * * *' ,
45+ interval : ' 0 9 * * *' , // Daily at 9 AM
4646});
4747
4848console .log (' Monitor created:' , monitor .data .id );
@@ -62,7 +62,7 @@ curl -X POST https://api.scrapegraphai.com/api/v2/monitor \
6262 "name": "Price Tracker",
6363 "url": "https://example.com/products",
6464 "prompt": "Extract current product prices",
65- "cron ": "0 9 * * *"
65+ "interval ": "0 9 * * *"
6666 }'
6767```
6868
@@ -75,9 +75,9 @@ curl -X POST https://api.scrapegraphai.com/api/v2/monitor \
7575| name | string | Yes | A descriptive name for the monitor. |
7676| url | string | Yes | The URL to monitor. |
7777| prompt | string | Yes | What data to extract on each run. |
78- | cron | string | Yes | Cron expression for the schedule (e.g., ` "0 9 * * *" ` for daily at 9 AM). |
79- | output_schema | object | No | Pydantic or Zod schema for structured response format. |
80- | fetch_config | FetchConfig | No | Configuration for page fetching (headers, stealth , etc.). |
78+ | interval | string | Yes | Cron expression for the schedule (5 fields, e.g., ` "0 9 * * *" ` for daily at 9 AM). |
79+ | output_schema | object | No | JSON Schema (Python dict / JS object) for structured response format. |
80+ | fetch_config | FetchConfig | No | Configuration for page fetching (mode, headers, wait , etc.). |
8181| llm_config | LlmConfig | No | Configuration for the AI model (temperature, max_tokens, etc.). |
8282
8383<Note >
@@ -123,23 +123,35 @@ client.monitor.delete(monitor_id)
123123### With Output Schema and Config
124124
125125``` python
126- from pydantic import BaseModel, Field
127126from scrapegraph_py import Client, FetchConfig, LlmConfig
128127
129- class ProductPrice (BaseModel ):
130- name: str = Field(description = " Product name" )
131- price: float = Field(description = " Current price" )
132- in_stock: bool = Field(description = " Whether the product is in stock" )
128+ schema = {
129+ " type" : " object" ,
130+ " properties" : {
131+ " products" : {
132+ " type" : " array" ,
133+ " items" : {
134+ " type" : " object" ,
135+ " properties" : {
136+ " name" : {" type" : " string" },
137+ " price" : {" type" : " number" },
138+ " in_stock" : {" type" : " boolean" },
139+ },
140+ " required" : [" name" , " price" ],
141+ },
142+ },
143+ },
144+ }
133145
134146client = Client(api_key = " your-api-key" )
135147
136148monitor = client.monitor.create(
137149 name = " Product Price Monitor" ,
138150 url = " https://example.com/products" ,
139151 prompt = " Extract product names, prices, and stock status" ,
140- cron = " 0 */6 * * *" , # Every 6 hours
141- output_schema = ProductPrice ,
142- fetch_config = FetchConfig(stealth = True ),
152+ interval = " 0 */6 * * *" , # Every 6 hours
153+ output_schema = schema ,
154+ fetch_config = FetchConfig(mode = " js+ stealth" , wait = 2000 ),
143155 llm_config = LlmConfig(temperature = 0.1 ),
144156)
145157```
@@ -156,7 +168,7 @@ async def main():
156168 name = " Tracker" ,
157169 url = " https://example.com" ,
158170 prompt = " Extract prices" ,
159- cron = " 0 9 * * *" ,
171+ interval = " 0 9 * * *" ,
160172 )
161173
162174 monitors = await client.monitor.list()
0 commit comments