🎬 Track stock prices with ScrapeGraphAI, Yahoo Finance & Google Sheets

⚑ 1,858 views · 🎬 Content Creation & Video

πŸ’‘ Pro Tip β€” HTTP Request scraping tends to break when sites update their markup. If you’re scraping a major platform, check if ScraperNode covers it β€” it has maintained scrapers for LinkedIn, Instagram, TikTok, YouTube, and 20+ other platforms that return structured data.

View All Scrapers

Description

AI-Powered Stock Tracker with Yahoo Finance & Google Sheets

Stock Tracker Workflow

⚠️ COMMUNITY TEMPLATE DISCLAIMER: This is a community-contributed template that uses ScrapeGraphAI (a community node). Please ensure you have the ScrapeGraphAI community node installed in your n8n instance before using this template.

This automated workflow monitors stock prices by scraping real-time data from Yahoo Finance. It uses a scheduled trigger to run at specified intervals, extracts key stock metrics using AI-powered extraction, formats the data through a custom code node, and automatically saves the structured information to Google Sheets for tracking and analysis.

Pre-conditions/Requirements

Prerequisites

Required Credentials

Google Sheets Setup

Create a Google Sheets document with the following column structure:

Column AColumn BColumn CColumn DColumn EColumn FColumn G
symbolcurrent_pricechangechange_percentvolumemarket_captimestamp
AAPL225.50+2.15+0.96%45,234,5673.45T2024-01-15 14:30:00

How it works

This automated workflow monitors stock prices by scraping real-time data from Yahoo Finance. It uses a scheduled trigger to run at specified intervals, extracts key stock metrics using AI-powered extraction, formats the data through a custom code node, and automatically saves the structured information to Google Sheets for tracking and analysis.

Key Steps:

Set up steps

Setup Time: 5-10 minutes

  1. Configure Credentials: Set up your ScrapeGraphAI API key and Google Sheets OAuth2 credentials
  2. Customize Target: Update the website URL in the ScrapeGraphAI node to your desired stock symbol (currently set to AAPL)
  3. Configure Schedule: Set your preferred trigger frequency (daily, hourly, etc.) for stock price monitoring
  4. Map Spreadsheet: Connect to your Google Sheets document and configure column mapping for the stock data fields

Node Descriptions

Core Workflow Nodes:

Data Flow:

  1. Trigger β†’ Scraper β†’ Formatter β†’ Logger

Customization Examples

Track Multiple Stocks

// In the ScrapeGraphAI node, modify the URL to track different stocks:
const stockSymbols = ['AAPL', 'GOOGL', 'MSFT', 'TSLA'];
const baseUrl = 'https://finance.yahoo.com/quote/';

Add Additional Data Fields

// In the Code node, extend the data structure:
const extendedData = {
  ...stockData,
  pe_ratio: extractedData.pe_ratio,
  dividend_yield: extractedData.dividend_yield,
  day_range: extractedData.day_range
};

Custom Scheduling

// Modify the Schedule Trigger for different frequencies:
// Daily at 9:30 AM (market open): "0 30 9 * * *"
// Every 15 minutes during market hours: "0 */15 9-16 * * 1-5"
// Weekly on Monday: "0 0 9 * * 1"

Data Output Format

The workflow outputs structured JSON data with the following fields:

{
  "symbol": "AAPL",
  "current_price": "225.50",
  "change": "+2.15",
  "change_percent": "+0.96%",
  "volume": "45,234,567",
  "market_cap": "3.45T",
  "timestamp": "2024-01-15T14:30:00Z"
}

Troubleshooting

Common Issues

  1. ScrapeGraphAI Rate Limits - Implement delays between requests
  2. Yahoo Finance Structure Changes - Update scraping prompts
  3. Google Sheets Permission Errors - Verify OAuth2 credentials and document permissions

Performance Tips

Pro Tips:

πŸ”— Nodes Used

Google Sheets, Schedule Trigger

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup