Environment:AI4Finance Foundation FinGPT BeautifulSoup
| Knowledge Sources | |
|---|---|
| Domains | Web_Scraping, NLP |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
BeautifulSoup4 HTML/XML parsing library for scraping financial news articles from Yahoo Finance, CNBC, MarketScreener, Seeking Alpha, and Google.
Description
This environment provides the `beautifulsoup4` (bs4) and `lxml` libraries used by the RAG multisource retrieval news scraper. The `scraping_by_url` orchestrator dispatches to site-specific scrapers that use `BeautifulSoup` to parse HTML content (`html.parser`, `lxml`, `lxml-xml`) and extract article text. The `requests_url` helper handles anti-bot headers.
Usage
Use this environment for Multi-Source News Scraping and Retrieval Augmented Generation workflows. Required by `scraping_by_url` and all site-specific scraper implementations.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Any | Cross-platform |
| Hardware | CPU sufficient | No GPU needed |
| Network | Internet | Required for scraping live sites |
Dependencies
Python Packages
- `beautifulsoup4` >= 4.12.2
- `lxml` >= 4.9.3
- `soupsieve` >= 2.5
- `requests` >= 2.31.0
Credentials
No credentials required for public news sites. Twitter scraping uses API tokens (see Environment:AI4Finance_Foundation_FinGPT_Selenium).
Quick Install
pip install beautifulsoup4>=4.12.2 lxml>=4.9.3 soupsieve>=2.5 requests>=2.31.0
Code Evidence
BeautifulSoup with lxml-xml parser from `fingpt/FinGPT_RAG/multisource_retrieval/news_scraper.py:75-76`:
response = requests_get(link)
soup = BeautifulSoup(response.content, 'lxml-xml')
Multi-source dispatch from `fingpt/FinGPT_RAG/multisource_retrieval/news_scraper.py:64-100`:
def scraping_by_url(link, subject):
if "seekingalpha.com" in link:
...
elif "reuters.com" in link:
...
elif "marketscreener.com" in link:
...
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `FeatureNotFound: Couldn't find a tree builder` | lxml not installed | `pip install lxml` |
| `HTTP 403 Forbidden` | Anti-bot blocking | Use `requests_url.requests_get` with rotating headers |
| `NoneType has no attribute text` | Page structure changed | Update CSS selectors for the specific news source |
Compatibility Notes
- Parsers: `lxml-xml` for XML sitemaps (Seeking Alpha); `html.parser` or `lxml` for HTML pages.
- Anti-bot: Use the `requests_url` helper which rotates user agents and headers.
- Rate limiting: Add delays between requests to avoid IP bans.