File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 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) {
8181 console . log ( scrape_result . result . browser_data ) ;
8282}
8383
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+
84106/* Scrapfly Extraction API offers LLM (Language Learning Model) based extraction
85107 * This example demonstrates how to use LLM query HTML files
86108 * 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) {
8181 console . log ( scrape_result . result . browser_data ) ;
8282}
8383
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+
84105/* Scrapfly Extraction API offers LLM (Language Learning Model) based extraction
85106 * This example demonstrates how to use LLM query HTML files
86107 * https://scrapfly.io/docs/extraction-api/llm-prompt
@@ -233,6 +254,7 @@ module.exports = {
233254 getAccount,
234255 basicGet,
235256 JSRender,
257+ scrapeExtraction,
236258 extractionLLM,
237259 extractionAutoExtract,
238260 extractionTemplates,
You can’t perform that action at this time.
0 commit comments