Selaa lähdekoodia

updated example

Mish Ushakov 1 vuosi sitten
vanhempi
commit
c965c24ff0
1 muutettua tiedostoa jossa 9 lisäystä ja 3 poistoa
  1. 9 3
      tests/lib.ts

+ 9 - 3
tests/lib.ts

@@ -2,22 +2,28 @@ import z from 'zod'
 import { chromium } from 'playwright'
 import LLMScraper from '../src'
 
+// Create a new browser instance
 const browser = await chromium.launch()
+
+// Initialize the LLMScraper instance
 const scraper = new LLMScraper(browser)
 
+// Define schema to extract contents into
 const schema = z.object({
   title: z.string().describe('Title of the page'),
 })
 
-const urls = ['https://example.com']
+// URLs to scrape
+const urls = ['https://example.com', 'https://browserbase.com']
 
+// Run the scraper
 const pages = await scraper.run(urls, {
   schema,
   mode: 'text',
   closeOnFinish: true,
 })
 
-// Stream the pages
+// Stream the result from LLM
 for await (const page of pages) {
-  console.log(page.data?.title)
+  console.log(page.data)
 }