Overview of Macrotrends Data Extraction Patterns
mainMacrotrends (https://www.macrotrends.net) provides historical financial and economic data. For read-only tasks, never use a browser; all data can be accessed via direct http_get requests to specific PHP endpoints or JSON APIs using a standard Mozilla/5.0 User-Agent. If you encounter 403 errors, switch to a Chrome User-Agent.
There are three primary access patterns based on the data type:
| Goal | Pattern | Data Variable | Latency | URL Component |
|---|---|---|---|---|
| Stock OHLCV price history | Direct iframe PHP | dataDaily | ~190ms | stock_price_history.php |
| Stock market cap (daily) | Direct iframe PHP | chartData | ~200ms | market_cap.php |
| Stock fundamentals (PE, revenue, margins) | Direct iframe PHP | chartData | ~140ms | fundamental_iframe.php or fundamental_metric.php |
| S&P 500 / composite index charts | chart_iframe_comp.php | originalData | ~90ms | chart_iframe_comp.php |
| Economic indicators (rates, yields, CPI) | /economic-data/ JSON API | data[] array | ~150ms | /economic-data/ |
| Gold, commodity prices | Either path | data[] or originalData | ~150ms | Varies |