let json_schema = json!({
"type": "object",
"properties": {
"top": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"points": {"type": "number"},
"by": {"type": "string"},
"commentsURL": {"type": "string"}
},
"required": ["title", "points", "by", "commentsURL"]
},
"minItems": 5,
"maxItems": 5,
"description": "Top 5 stories on Hacker News"
}
},
"required": ["top"]
});
let llm_extraction_params = json!({
"extractorOptions": {
"extractionSchema": json_schema
}
});
let scrape_result = app.scrape_url("https://news.ycombinator.com", Some(llm_extraction_params)).await;
match scrape_result {
Ok(data) => println!("LLM Extraction Result: {}", data),
Err(e) => eprintln!("Failed to perform LLM extraction: {}", e),
}