I am interested in possible methods of automatically converting the prices given when a web page is loaded from the currency given to a specified currency. Ideally, the conversion would also make use of the current exchange rate to give valid prices.
For example, in my specific case, I would like to convert the prices given in Euros (€) on this web site to Sterling (£).
I am looki开发者_运维百科ng at using a GreaseMonkey script for this conversion, but can anyone suggest other methods?
Thanks, MagicAndi.
Try the API: http://thecurrencygraph.com
It uses Geo Location scripts to detect the user's country and through that their native currency. It then converts your prices into their currency using the latest exchange rates
Hope this this helps!
W.
Since I dabble in AutoHotkey here's a potential solution using that scripting language, it retrieves the page source from a webpage that does the conversion and parses out the converted value. This requires the httpQuery library to be included:
#Include httpQuery.ahk
InputBox, n, EUR to GBP, Enter the number., , 150, 120
if (ErrorLevel || !n)
return
url := "http://www.xe.com/ucc/convert.cgi?Amount=" n "&From=EUR&To=GBP&image.x=55&image.y=8"
html := URLDownloadToVar(url)
Gui, Add, Edit, w125, % RegExMatch(html,"[\d\.]+(?= GBP)",m) ? m "£" : "The value could not be retrieved."
Gui, Show, AutoSize Center, GBP
VarSetCapacity(html,0)
Return
GuiClose:
GuiEscape:
Gui, Destroy
return
URLDownloadToVar(url){
if !RegExMatch(url,"^http://")
url := "http://" url
httpQuery(html,url)
VarSetCapacity(html, -1)
Return html
}
There are obviously more thorough (and complex) methods for solving this problem but this at least solves it with minimal effort.
The quick and easy answer is to make use of a Firefox add-on. There are a number of currency converters available as add-ons, but I ended up using Exch, as it suited my needs best.
精彩评论