egoselfaxis
asked on
Retrieving the current gold price (CGP) using PHP
Does anyone here know how I might retrieve the current gold price (in US dollars) using PHP?
Ideally, I'd like to see an example PHP script that retrieves the current gold price (from some kind of remote data feed provider, I'm assuming) and then displays it on the page.
Thanks,
- Yvan
Ideally, I'd like to see an example PHP script that retrieves the current gold price (from some kind of remote data feed provider, I'm assuming) and then displays it on the page.
Thanks,
- Yvan
Finding a reliable feed is your first issue. Do you know of one?
Using this search, ...
http://lmgtfy.com/?q=Spot+Price+Gold
... I found this data source:
http://www.goldprice.org/
I'll post a script to give you the "scrape" of this page in just a moment.
http://lmgtfy.com/?q=Spot+Price+Gold
... I found this data source:
http://www.goldprice.org/
I'll post a script to give you the "scrape" of this page in just a moment.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Ray! Your script works beautifully.
- Yvan
- Yvan
Thanks for the points. The strategy of "scraping" a web page is a little bit brittle - a change by the author of the page can break your scrape script. So it is fairly important to check for errors and report them in a timely way. You might consider sending yourself an email message if the script makes an error or reports data with a timestamp that is too old. Just a thought.