Structured Web Scraping with Google Gemini and Langchain - n8n Workflow

Use this powerful n8n workflow to combine real-time web scraping with Google Gemini (Langchain n8n node) to extract, analyze, and structure complex product data into clean JSON.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Data Engineers needing to extract structured data from complex websites.
Automation developers looking for advanced n8n templates integrating Langchain.
Users requiring real-time web scraping and AI-powered data normalization.
Anyone interested in leveraging the Google Gemini n8n node for data analysis.

Overview

This comprehensive n8n workflow solves the problem of extracting meaningful, structured data from poorly formatted or complex website content. Instead of relying solely on brittle CSS selectors common in typical web scraping, this n8n automation first fetches the raw HTML, extracts potential inline data scripts (often rich JSON embedded by sites like Product Hunt), and then utilizes the Google Gemini Large Language Model (LLM) via the Langchain n8n node integration to analyze and normalize that data.

The result is a highly reliable process that turns messy script fragments into clean, predefined JSON objects. This approach makes the n8n workflow highly resilient to minor website layout changes and is a cornerstone among modern n8n templates for AI-powered extraction.

How it Works

The entire process is managed efficiently within a single n8n workflow, starting with an external request and ending with a structured data response.


  1. Trigger Initiation: The automation begins with the Receive Product Request n8n trigger, which is a Webhook set to listen for incoming requests, typically containing a product identifier in the query parameters.

  2. Data Fetching: The Fetch Product HTML n8n node uses an HTTP Request to pull the raw HTML content of the target product page.

  3. Pre-processing: The Extract Inline Scripts custom Code n8n node meticulously parses the raw HTML, isolating and extracting the rich data contained within inline JavaScript or application scripts.

  4. LLM Configuration: Two helper n8n nodes configure the AI operation: Analyze Script with Google Gemini (defining the LLM) and Format Product Data to JSON (defining the desired output schema using the structured output parser).

  5. AI Processing: The Process Script with LLM n8n node acts as the Langchain orchestrator. It feeds the extracted script data into the Google Gemini LLM, instructing it to strictly conform to the JSON schema defined by the output parser n8n node. This ensures the extracted data is clean.

  6. Final Response: The structured data, now formatted as clean JSON, is immediately returned to the calling client using the Send JSON Response to Client n8n node, completing the real-time request.

Installation Guide

To install this robust n8n workflow, follow these steps:


  1. Import: Copy the provided JSON code and import it directly into your n8n instance via the Workflows menu (New > Import from JSON).

  2. Webhook Setup: After importing, activate the Receive Product Request n8n trigger node. Copy the generated test webhook URL.

  3. Credentials: You must configure the Langchain n8n node integration:

Set up credentials for the Analyze Script with Google Gemini n8n node, providing your Google Gemini API Key.
Ensure the Code n8n node (Extract Inline Scripts) is correctly configured to parse the specific structure of the website you are targeting (Product Hunt in this case, often requiring minor adjustments).

  1. Testing: Execute the n8n workflow by sending a POST request to the webhook URL, including the necessary query parameter (e.g., ?product=example_name).

Node Details

This n8n template utilizes several specialized n8n node types to achieve complex data extraction:

Receive Product Request (Webhook n8n trigger): The starting point. It enables external systems to initiate the n8n workflow, typically passing the required product page URL or identifier.
Fetch Product HTML (HTTP Request n8n node): Responsible for fetching the source HTML of the target product page. Key configuration involves setting the target URL based on the initial webhook input.
Extract Inline Scripts (Code n8n node): This crucial n8n node contains custom JavaScript logic to efficiently parse the large HTML body and extract the hidden data scripts, preparing them for the LLM. This step greatly improves the quality of data provided to Gemini.
Analyze Script with Google Gemini (Langchain LM Chat Google Gemini n8n node): Defines the LLM used for analysis. Requires setting up the Google API credentials.
Format Product Data to JSON (Langchain Output Parser Structured n8n node): Defines the exact JSON structure (schema) that the LLM must adhere to when generating its response, enforcing data quality and consistency.
Process Script with LLM (Langchain Chain LLM n8n node): The core processing n8n node that links the input data, the Google Gemini model, and the structured output parser, executing the AI transformation task.


  • Send JSON Response to Client (Respond To Webhook n8n node): Final step, sending the clean, structured data back to the originating client, showcasing the utility of this powerful n8n workflow.

Related n8n Workflows

Paid

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by

Automation consultant with over 10 years of experience specializing in AI, no-code, and workflow optimization. I’ve delivered tailored AI and NLP solutions across real estate, healthcare, and more, enhancing efficiency and customer experiences. Proficient in tools like Make, Airtable, and Zapier, I also integrate GPT models to create scalable, innovative automations. Contact me to discuss custom n8n workflows or advanced automations to streamline your processes.

Featured*