求助:谷歌表格抓取ASX实时精准股价(解决IMPORTXML无效问题)
Hey Ian, I’ve run into this exact ASX stock price snag in Google Sheets before—let’s break down why your current methods aren’t working and get you that precise, up-to-date penny stock price you need.
Why Your Existing Approaches Are Falling Short
Let’s start with the root causes:
GOOGLEFINANCEinstant price limitation: The formula=googlefinance("ASX.NEA","price")rounds penny stock prices (like your example 0.910) to fewer decimal places, which wipes out the precision you’re after.- Historical
GOOGLEFINANCEworkaround: YourINDEX-based formula for historical prices gives accurate precision, but it only pulls data from prior days—no way to grab today’s live price with this method. IMPORTXMLfailure: ASX loads share prices dynamically using AngularJS (you spotted theng-showattributes in the source code).IMPORTXMLonly reads the static HTML that loads when the page first opens, which doesn’t include the actual price value—hence the #N/A error.
The Reliable Solution: Use ASX’s Public API
ASX offers a free, structured JSON API that serves raw, unrounded stock data—perfect for your penny stock needs. Here’s how to use it in Google Sheets:
Step-by-Step Formula
Use IMPORTDATA to pull the JSON data, then JSON_EXTRACT_SCALAR to grab the exact last price:
=JSON_EXTRACT_SCALAR(IMPORTDATA("https://www.asx.com.au/asx/1/share/NEA"), "$.last_price")
- This returns the full-precision price (e.g., 0.910 instead of 0.91)
- The API updates in real-time, so you’ll get the latest available price for the day
- No fragile XPath selectors that break if ASX tweaks their page layout
How It Works
The ASX API endpoint https://www.asx.com.au/asx/1/share/NEA sends back a JSON object with all key stock details. The $.last_price path targets the exact field holding the unrounded, current price. JSON_EXTRACT_SCALAR pulls that single value out of the JSON response cleanly.
Bonus: Refresh Settings
Google Sheets automatically refreshes the IMPORTDATA feed periodically, but if you want more control:
- Go to File > Spreadsheet settings
- Under the Calculation tab, adjust the "Recalculation" interval to your preference (e.g., "On change and every minute")
内容的提问来源于stack exchange,提问作者Ian Finlay

