/    Sign up×
Community /Pin to ProfileBookmark

Real Time Currency rates

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.

to post a comment

3 Comments(s)

Copy linkTweet thisAlerts:
@donatelloDec 18.2010 — If you are looking for Euro rates the ECB has a feed. I use it on a site, you can see it here:

dollars to euro


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 -->

<div class="forextable">
<?php

$page = file_get_contents("http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html");

//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];


$endresult = str_replace('href="eurofxref','target="_blank" rel="nofollow" href="http://www.ecb.int/stats/exchange/eurofxref/html/eurofxref', $endresult);
$endresult = str_replace('href="/rss','target="_blank" rel="nofollow" href="http://www.ecb.int/rss', $endresult);




print $endresult;


?>
</div></div>
<p>&nbsp;</p>
<?php } ?><!-- End of Wordpress conditional tag -->
<!-- Currency rates on home page only END -->
[/code]
Copy linkTweet thisAlerts:
@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:

ETF Portfolios
Copy linkTweet thisAlerts:
@anothenauthorDec 18.2010 — thx donatello, I'll check into it.
×

Success!

Help @anothen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...