---
title: "Web scraping stock prices"
description: "Web scraping stock prices, historical OHLC data, fundamentals and ticker news from Yahoo Finance, Nasdaq and MarketWatch, returned as structured JSON."
canonical: https://www.zenrows.com/use-cases/web-scraping-stock-prices
updated: 2026-11-02
---

# Web scraping stock prices

Web scraping stock prices means collecting quotes, historical prices, fundamentals and headlines from finance portals like Yahoo Finance, Nasdaq and MarketWatch. Zenrows renders those pages, captures the JSON they load in the background or the fields you name with CSS selectors, and returns structured data for spreadsheets, dashboards and backtests.

## Sample output: one stock quote

```json
{
  "symbol": "EXMP",
  "exchange": "NASDAQ",
  "source_url": "https://finance.example.com/quote/EXMP",
  "price": 184.27,
  "change": -2.13,
  "change_pct": -1.14,
  "currency": "USD",
  "market_state": "closed",
  "quote_time": "2026-10-16T20:00:00Z",
  "captured_at": "2026-10-16T20:05:31Z",
  "open": 186.10,
  "day_range": [182.90, 187.45],
  "volume": 31842210,
  "market_cap": 412500000000,
  "pe_ratio_ttm": 27.4,
  "eps_ttm": 6.73,
  "dividend_yield": 0.0061,
  "fifty_two_week_range": [141.20, 199.80],
  "next_earnings_date": "2026-10-29"
}
```

Illustrative, fictional ticker. `quote_time` is the portal's time for the price; `captured_at` is when you read the page.

## What stock data scraping covers

Portals spread one ticker across tabs (quote, history, statistics, news), each its own page with its own refresh rhythm.

| Job | Data you collect | Typical sources |
|---|---|---|
| End-of-day price capture | Close, open, high, low, volume | Yahoo Finance, Nasdaq, MarketWatch quote pages |
| Historical price tables | Daily or weekly OHLC, adjusted close, splits, dividends | Yahoo Finance and Nasdaq history tabs, Barchart |
| Fundamentals snapshots | Market cap, P/E, EPS, yield, shares outstanding | Statistics and financials tabs, Zacks, GuruFocus, Morningstar |
| Earnings and analyst calendars | Report dates, consensus, rating changes | Nasdaq earnings calendar, MarketWatch, Zacks |
| Ticker news and chatter | Headlines, timestamps, tickers, message volume | Yahoo Finance news, Seeking Alpha, StockTwits, Reddit |
| Non-US listings | Local quotes, currency, exchange suffixes | finanzen.net, BSE India, Google Finance |

## Why stock price scrapers break

It starts as a few lines of `requests` and BeautifulSoup, and breaks when the portal moves the price to a background call or challenges repeat visitors.

| What breaks | What it looks like | How Zenrows handles it |
|---|---|---|
| Price loads after the page | Layout but no price, or a placeholder dash | A full render with XHR capture returns the page plus the quote data |
| Consent and regional pages | Some countries get a cookie consent page instead | Geotargeting picks the market; page actions click through consent |
| Blocks when polling many tickers | 429s or challenges after hundreds of requests from one IP | Zenrows' stealth keeps polling unblocked; Batch runs the list as one job |
| Formatted numbers | Strings like "412.5B", "N/A" or "-1.14%" | CSS selectors return exactly those cells, for one parsing function |
| Layout changes | A redesign renames classes; selectors return nothing | Extract returns JSON without selectors |
| Mixed timestamps | A delayed quote stored as live | Store the portal's quote time with your capture time |

## How to scrape stock prices with Zenrows

1. **List the tickers and pages:** quote, history and statistics URLs from each portal's pattern.
2. **Capture the quote data:** full render with network capture; keep the call carrying the price.
3. **Name fields where the HTML is enough:** CSS selectors for statistics and calendars, with Adaptive Stealth Mode for access.
4. **Run the watchlist after the close** in Batch, daily or at your dashboard's interval.
5. **Validate before storing** against the previous day and a reference close.

```python Python
# pip install requests
import json
import requests

params = {
    "apikey": "YOUR_ZENROWS_API_KEY",
    "url": QUOTE_URL,  # a portal's quote page for one ticker
    "js_render": "true",
    "premium_proxy": "true",
    "json_response": "true",
}
data = requests.get("https://api.zenrows.com/v1/", params=params).json()

# The page loads the price in a background call; keep the one that holds it
for call in data["xhr"]:
    if "quote" in call["url"] and call["status_code"] == 200:
        print(json.loads(call["body"]))
```

```bash cURL
curl -G "https://api.zenrows.com/v1/" \
  --data-urlencode "apikey=YOUR_ZENROWS_API_KEY" \
  --data-urlencode "url=STATISTICS_URL" \
  --data-urlencode "mode=auto" \
  --data-urlencode 'css_extractor={"market_cap":"[data-field=marketCap]","pe_ratio":"[data-field=peRatio]","dividend_yield":"[data-field=dividendYield]"}'
```

```bash CLI
npx -y @zenrows/cli init
zenrows extract https://finance.yahoo.com/quote/AAPL/history/ --outputs tables
zenrows extract https://finance.yahoo.com/quote/AAPL/key-statistics/ --autoparse
# watchlist.jsonl: one {"url": "..."} per quote or history page
zenrows batch create watchlist.jsonl --wait
```

```text Claude Code (MCP)
# Connect once
claude mcp add zenrows -e ZENROWS_API_KEY=YOUR_ZENROWS_API_KEY -- npx -y @zenrows/mcp

# Then ask:
Use Zenrows to read the Yahoo Finance quote pages for AAPL, MSFT and NVDA and return a JSON list with ticker, last price, change percent, market cap, P/E ratio and the quote time shown on each page.
```

## Which Zenrows product fits

| If you need to | Use | Why |
|---|---|---|
| Read one quote page with background-loaded data | [Fetch](/products/fetch) | XHR calls plus the rendered HTML |
| Get history tables or stats without selectors | [Extract](/products/extract) | JSON that adapts when the layout changes |
| Refresh hundreds of tickers daily | [Batch](/products/batch) | One job, results by webhook |
| Try a page from the terminal first | [CLI](/cli) | The page as JSON or Markdown in one command |

## What success looks like

| Measure | What good looks like | How to check it |
|---|---|---|
| Price accuracy | Closes match the official close | Weekly reconcile of a random sample |
| Ticker coverage | Every symbol, every trading day | Missing symbol-date pairs per run |
| Timestamp hygiene | Quote time and capture time on each record | Reject empty or unexpectedly old quote times |
| Parse rate | Clean numbers; "N/A" and dashes as nulls | Type-check failures per portal |
| Run time | Done well before the dashboard or backtest reads it | Batch start and finish against ticker count |

## Web scraping stock prices FAQ

### Can you scrape stock prices from Yahoo Finance?

Yes. Yahoo Finance loads parts of its quote pages with JavaScript, so render them and capture the background calls, including the one carrying the quote. Zenrows' stealth keeps requests going across many tickers. The same works for Nasdaq.com, MarketWatch and most portals.

### Is it legal to scrape stock prices?

Public portal prices are widely used for personal research and internal analysis. Redistribution differs: exchange data is licensed and portal terms often restrict commercial reuse. Check each site's terms and licensing, and ask your legal team before publishing or reselling.

### How do I scrape historical stock data?

Open the ticker's history page with the date range in the URL and use Extract or the tables output filter for JSON rows. Backfill once, then append daily. Store splits and dividends, often in the same table, as separate events.

### How often can I refresh stock prices?

You set the interval: every few minutes intraday, daily for research. Many portals show delayed quotes and say so, so store the quote time. End-of-day after the close is the most common schedule.

### How do I build a stock scraper in Python?

Call the Zenrows API with requests , the quote URL and the parameters above, and read the JSON. Zenrows handles rendering, stealth and retries; your code builds URLs, parses fields and stores rows. Past a few hundred tickers, use Batch.

### How do I scrape stock news for a ticker?

Use the symbol's news tab, on Yahoo Finance or MarketWatch for example. Fetch it as Markdown or name headline, source, link and time with CSS selectors; store each with ticker and capture time, deduplicated on article URL since stories repeat across portals.

### Can I scrape fundamentals and earnings dates too?

Yes. Statistics, financials and earnings calendars are separate URLs per ticker. Use CSS selectors or Extract, and store dated snapshots: market cap and P/E change daily.

## Related use cases

- [Financial data scraping](https://www.zenrows.com/use-cases/financial-data-scraping.md): Rate tables, IR pages, filings, fund data and central bank releases, as JSON tables and Markdown documents.
- [Alternative data for investors](https://www.zenrows.com/use-cases/alternative-data.md): Hiring, pricing, app ranks, reviews and store counts per ticker, collected weekly as point-in-time series.
- [News monitoring](https://www.zenrows.com/use-cases/news-monitoring.md): Alerts on new stories about your companies, people and keywords, polled from feeds, wires and publisher pages.
- [Sentiment analysis data](https://www.zenrows.com/use-cases/sentiment-analysis-data.md): Review text with ratings, forum threads and comments, cleaned and labeled for sentiment and NLP models.
- [News scraping](https://www.zenrows.com/use-cases/news-scraping.md): Full-text articles, headlines, bylines and dates from publishers, Google News and wires, as clean Markdown or JSON.

Start free: https://app.zenrows.com/register. Docs: https://docs.zenrows.com

## Structured data



<script type="application/ld+json">
{"@context":"https://schema.org","@graph":[{"@type":"WebPage","@id":"https://www.zenrows.com/use-cases/web-scraping-stock-prices#webpage","url":"https://www.zenrows.com/use-cases/web-scraping-stock-prices","name":"Web scraping stock prices","description":"Web scraping stock prices, historical OHLC data, fundamentals and ticker news from Yahoo Finance, Nasdaq and MarketWatch, returned as structured JSON.","isPartOf":{"@id":"https://www.zenrows.com/#website"},"inLanguage":"en","datePublished":"2026-11-02","dateModified":"2026-11-02","about":{"@type":"Thing","name":"web scraping stock prices"},"keywords":"web scraping stock prices, stock market data scraping, web scraping stock data, stock scraper, scrape stock prices python, scrape yahoo finance, historical stock data scraping, stock price scraper","publisher":{"@type":"Organization","name":"Zenrows","url":"https://www.zenrows.com/"}},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://www.zenrows.com/"},{"@type":"ListItem","position":2,"name":"Use cases","item":"https://www.zenrows.com/use-cases"},{"@type":"ListItem","position":3,"name":"Web scraping stock prices","item":"https://www.zenrows.com/use-cases/web-scraping-stock-prices"}]},{"@type":"FAQPage","@id":"https://www.zenrows.com/use-cases/web-scraping-stock-prices#faq","mainEntity":[{"@type":"Question","name":"Can you scrape stock prices from Yahoo Finance?","acceptedAnswer":{"@type":"Answer","text":"Yes. Yahoo Finance loads parts of its quote pages with JavaScript, so render them and capture the background calls, including the one carrying the quote. Zenrows' stealth keeps requests going across many tickers. The same works for Nasdaq.com, MarketWatch and most portals."}},{"@type":"Question","name":"Is it legal to scrape stock prices?","acceptedAnswer":{"@type":"Answer","text":"Public portal prices are widely used for personal research and internal analysis. Redistribution differs: exchange data is licensed and portal terms often restrict commercial reuse. Check each site's terms and licensing, and ask your legal team before publishing or reselling."}},{"@type":"Question","name":"How do I scrape historical stock data?","acceptedAnswer":{"@type":"Answer","text":"Open the ticker's history page with the date range in the URL and use Extract or the tables output filter for JSON rows. Backfill once, then append daily. Store splits and dividends, often in the same table, as separate events."}},{"@type":"Question","name":"How often can I refresh stock prices?","acceptedAnswer":{"@type":"Answer","text":"You set the interval: every few minutes intraday, daily for research. Many portals show delayed quotes and say so, so store the quote time. End-of-day after the close is the most common schedule."}},{"@type":"Question","name":"How do I build a stock scraper in Python?","acceptedAnswer":{"@type":"Answer","text":"Call the Zenrows API with requests , the quote URL and the parameters above, and read the JSON. Zenrows handles rendering, stealth and retries; your code builds URLs, parses fields and stores rows. Past a few hundred tickers, use Batch."}},{"@type":"Question","name":"How do I scrape stock news for a ticker?","acceptedAnswer":{"@type":"Answer","text":"Use the symbol's news tab, on Yahoo Finance or MarketWatch for example. Fetch it as Markdown or name headline, source, link and time with CSS selectors; store each with ticker and capture time, deduplicated on article URL since stories repeat across portals."}},{"@type":"Question","name":"Can I scrape fundamentals and earnings dates too?","acceptedAnswer":{"@type":"Answer","text":"Yes. Statistics, financials and earnings calendars are separate URLs per ticker. Use CSS selectors or Extract, and store dated snapshots: market cap and P/E change daily."}}]}]}
</script>
