I’ve been looking around the web trying to find out how real time rates of currency and stocks are done. I’ve found widgets and websites which do this, I was wondering how, and if I’m able to write this code for my own web page.
There was a wordpress plugin that showed a selectable rate and worked via AJAX but it stopped working... as you can see it is in the right sidebar. I don't really update this site as it does not get much traffic, so just left it out of sheer disgraceful laziness.
Here is the PHP script I use to scrape the rates...
There is a WordPress conditional tag in this script. [code=php] <!-- Currency Rates on home page only BEGIN -->
<?php if (is_front_page()) { ?><!-- Wordpress Conditional Tag BEGIN -->
//Above this line, ALL WORKS FINE! ////////////////////////////////////////////////////
// FOR you the $getpage should be the entire html you display on the page $explodefirst = explode('<div class="tab">',$page); $headerisgone = $explodefirst[1]; $explodesecond = explode('</div>',$headerisgone); $endresult = $explodesecond[0];
@donatelloDec 18.2010 — #I also had a screenscraper for Bloomberg, but they detect it and shut you off! There is a way to get stock quotes from Yahoo Finance... they seem to allow feeds.
A friend of mine uses it on his financial blog in a Wordpress plugin in the sidebar. Here's his site: