n8n workflow template · 14 nodes · Google Gemini
Vision-Based AI Agent Scraper - with Google Sheets, ScrapingBee, and Gemini is a free n8n workflow template that runs when another workflow calls it and works with Google Gemini and Google Sheets. It has 14 nodes, 4 of them AI nodes (Structured Output Parser, Google Gemini Chat Model, Call n8n Workflow Tool and AI Agent). The notes inside the workflow say: “This node uses ScrapingBee, a powerful scraping tool, to capture a screenshot of the desired URL. You can try ScrapingBee and enjoy 1,000 free requests (non-affiliate link).” To run it, you add your own credentials for Google Gemini (PaLM) API and Google Service Account.
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
This node uses ScrapingBee, a powerful scraping tool, to capture a screenshot of the desired URL. You can try ScrapingBee and enjoy 1,000 free requests (non-affiliate link).
Ensure the screenshot_full_page parameter is set to true for a full-page screenshot. This is crucial for vision-based scraping with the AI Agent.
Alternatively, you can choose to screenshot only a specific part of the page. However, keep in mind that the AI Agent will extract data only from the visible section—it has vision, but not a crystal ball!
This node serves as the entry point for the HTML scraping tool.
It is triggered by the AI Agent only when it fails to extract data from the screenshot. The URL is sent as a parameter for the query.
This is the central node of the workflow, powered by an AI Agent with two key prompts
Chosen because tests show that Gemini-1.5-Pro outperforms GPT-4 and GPT-4-Vision in visual tasks. Either my prompt wasn’t optimized for GPT models, or GPT might need glasses. Other multimodal LLMs haven’t been tested yet.
A fallback tool the agent uses if it cannot extract data directly from the screenshot.
Formats the extracted data into an easy-to-use structure, ready to be added to the results page in Google Sheets.
The default model is gemini-1.5-pro. It offers excellent performance for this use case, but it’s not the most cost-effective option—use it judiciously.
This tool is invoked when the AI Agent requires the HTML (converted to Markdown) to extract data because the screenshot alone wasn’t sufficient.
This node utilizes the ScrapingBee API to retrieve the HTML of the webpage.
This node organizes the extracted data into an easy-to-use JSON format.
In this template, the JSON is designed for an e-commerce webpage. Customize it to fit your specific needs.
This node converts the HTML from the previous node into Markdown format, helping to save tokens.
The converted Markdown is then automatically sent to the AI Agent through this node.
This node splits the array created by the Structured Output Parser into individual rows, making them easy to append to the subsequent Google Sheets node.
This node creates rows in the Results sheet using the extracted data.
You can use the example Google Sheet as a template. However, ensure that the columns in the Results sheet are aligned with the structure of the output from the Structured Output Parser node.
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
This workflow involves scraping, so make sure to check the legal regulations around scraping in your country before getting started. Better safe than sorry!
This workflow leverages a vision-based AI Agent, integrated with Google Sheets, ScrapingBee, and the Gemini-1.5-Pro model, to extract structured data from webpages. The AI Agent primarily uses screenshots for data extraction but switches to HTML scraping when necessary, ensuring high accuracy.
Key features include
This template is designed for e-commerce scraping but can be customized for various use cases.
The default trigger is When clicking ‘Test workflow’, meaning the workflow will need to be triggered manually.
You can replace this by selecting a trigger of your choice.
The Google Sheet will contain two sheets
Here is an example Google Sheet you can use. The "Results" sheet is pre-configured for e-commerce website scraping. You can adapt it to your specific needs, but remember to adjust the Structured Output Parser node accordingly.
This node allows you to define the fields that will be sent to the ScrapingBee HTTP Node and the AI Agent.
In this template, only one field is pre-configured: url. You can customize it by adding additional fields as needed.
This node sets the fields from the AI Agent’s query.
In this template, the only field configured is url.
The 14 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:
Configure your own credentials after importing. Create each credential in n8n, then select it in the node.
Do you need somewhere to run it? Read our guide to self-hosted n8n.
We can adapt this workflow to your apps, data and process, then deploy and support it.
Contact Us