Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AI4Finance Foundation FinGPT scraping by url

From Leeroopedia
Knowledge Sources
Domains Web_Scraping, Information_Retrieval, Finance
Last Updated 2026-10-18 00:00 GMT

Overview

Concrete tool for dispatching article scraping to source-specific extractors based on URL domain provided by the FinGPT RAG news scraper.

Description

The scraping_by_url function is the central orchestrator for multi-source financial news scraping. It examines the URL domain and dispatches to the appropriate source-specific scraper: Seeking Alpha (with XML sitemap support), Reuters, MarketScreener, Yahoo Finance, CNBC, or Google Search. Each scraper extracts article text and filters by relevance using `similarity_score` against the query subject.

If the article is relevant (similarity >= threshold, typically 0.8), the article text is appended to the subject as context. If not relevant, returns `("N/A", subject)`.

Usage

Import this function when you need to scrape financial news articles from multiple sources:

  • RAG context retrieval: Finding relevant news articles to augment sentiment classification.
  • Multi-source aggregation: Scraping from Yahoo, CNBC, Google, MarketScreener, Seeking Alpha.

Code Reference

Source Location

  • Repository: FinGPT
  • File: fingpt/FinGPT_RAG/multisource_retrieval/news_scraper.py
  • Lines: L64-346 (scraping_by_url + per-source dispatch), L348-433 (Seeking Alpha)

Signature

def scraping_by_url(
    link: str,
    subject: str,
) -> tuple[str, str]

Import

from news_scraper import scraping_by_url

I/O Contract

Inputs

Name Type Required Description
link str Yes Article URL to scrape
subject str Yes Topic/headline to match against (query)

Outputs

Name Type Description
return value tuple[str, str] (url, subject_with_context) if relevant, ("N/A", subject) if not

Usage Examples

Scrape Article from Yahoo Finance

from news_scraper import scraping_by_url

url, context = scraping_by_url(
    link="https://finance.yahoo.com/news/example-article",
    subject="Apple quarterly earnings report",
)
if url != "N/A":
    print("Found relevant article:", url)
    print("Context:", context[:200])

Related Pages

Implements Principle

Uses Heuristic

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment