File tree 2 files changed +44
-0
lines changed 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,28 @@ export async function JSRender(apiKey: string) {
81
81
console . log ( scrape_result . result . browser_data ) ;
82
82
}
83
83
84
+ /* Use AI extraction capabilities with the the web scraping API
85
+ * all Extraction API methods are supported, see below examples for more
86
+ */
87
+ export async function scrapeExtraction ( apiKey : string ) {
88
+ const client = new ScrapflyClient ( { key : apiKey } ) ;
89
+
90
+ let scrape_result = await client . scrape (
91
+ new ScrapeConfig ( {
92
+ url : 'https://web-scraping.dev/product/1' ,
93
+ // enable browsers:
94
+ render_js : true ,
95
+ // use LLM prompt for auto parsing
96
+ extraction_prompt : "Extract the product specification in json format" ,
97
+ } )
98
+ ) ;
99
+
100
+ // access the extraction result
101
+ console . log ( "extraction result:" ) ;
102
+ console . log ( scrape_result . result . extracted_data ) ;
103
+ }
104
+
105
+
84
106
/* Scrapfly Extraction API offers LLM (Language Learning Model) based extraction
85
107
* This example demonstrates how to use LLM query HTML files
86
108
* https://scrapfly.io/docs/extraction-api/llm-prompt
Original file line number Diff line number Diff line change @@ -81,6 +81,27 @@ async function JSRender(apiKey) {
81
81
console . log ( scrape_result . result . browser_data ) ;
82
82
}
83
83
84
+ /* Use AI extraction capabilities with the the web scraping API
85
+ * all Extraction API methods are supported, see below examples for more
86
+ */
87
+ async function scrapeExtraction ( apiKey ) {
88
+ const client = new ScrapflyClient ( { key : apiKey } ) ;
89
+
90
+ let scrape_result = await client . scrape (
91
+ new ScrapeConfig ( {
92
+ url : 'https://web-scraping.dev/product/1' ,
93
+ // enable browsers:
94
+ render_js : true ,
95
+ // use LLM prompt for auto parsing
96
+ extraction_prompt : "Extract the product specification in json format" ,
97
+ } )
98
+ ) ;
99
+
100
+ // access the extraction result
101
+ console . log ( "extraction result:" ) ;
102
+ console . log ( scrape_result . result . extracted_data ) ;
103
+ }
104
+
84
105
/* Scrapfly Extraction API offers LLM (Language Learning Model) based extraction
85
106
* This example demonstrates how to use LLM query HTML files
86
107
* https://scrapfly.io/docs/extraction-api/llm-prompt
@@ -233,6 +254,7 @@ module.exports = {
233
254
getAccount,
234
255
basicGet,
235
256
JSRender,
257
+ scrapeExtraction,
236
258
extractionLLM,
237
259
extractionAutoExtract,
238
260
extractionTemplates,
You can’t perform that action at this time.
0 commit comments