Implementation:AI4Finance Foundation FinGPT scraping by url
| 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
- Principle:AI4Finance_Foundation_FinGPT_Retrieval_Augmented_Generation
- Principle:AI4Finance_Foundation_FinGPT_Multi_Source_News_Scraping