This example shows how to analyze website content using Gemini’s multi-turn conversation capabilities.
import { extract } from 'scrapegraph-js';import { GoogleGenAI } from '@google/genai';const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });const result = await extract(process.env.SGAI_APIKEY!, { url: 'https://news.ycombinator.com/', prompt: 'Extract all content from this page',});const data = result.data?.json;console.log('Scraped content length:', JSON.stringify(data).length);const chat = ai.chats.create({ model: 'gemini-2.5-flash'});// Ask for the top 3 stories on Hacker Newsconst result1 = await chat.sendMessage({ message: `Based on this website content from Hacker News, what are the top 3 stories right now?\n\n${JSON.stringify(data)}`});console.log('Top 3 Stories:', result1.text);// Ask for the 4th and 5th stories on Hacker Newsconst result2 = await chat.sendMessage({ message: `Now, what are the 4th and 5th top stories on Hacker News from the same content?`});console.log('4th and 5th Stories:', result2.text);