自动将网页上的价格转换为不同的货币

发布于 2024-08-26 02:27:05 字数 264 浏览 5 评论 0原文

我对自动将网页加载时给出的价格从给定货币转换为指定货币的可能方法感兴趣。理想情况下,转换还可以利用当前汇率来给出有效的价格。

例如,在我的具体情况下,我想在此 web 上转换以欧元 (€) 给出的价格网站兑换为英镑(£)。

我正在考虑使用 GreaseMonkey 脚本进行此转换,但有人可以建议其他方法吗?

谢谢,魔术安迪。

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 looking at using a GreaseMonkey script for this conversion, but can anyone suggest other methods?

Thanks, MagicAndi.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橘寄 2024-09-02 02:27:05

尝试 API:http://thecurrencygraph.com

它使用地理位置脚本来检测用户的国家/地区并通过该国家/地区的本国货币。然后它会使用最新的汇率将您的价格转换成他们的货币

希望这会有所帮助!

W.

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.

无人接听 2024-09-02 02:27:05

由于我涉足 AutoHotkey 这里有一个使用该脚本语言的潜在解决方案,它检索来自进行转换并解析出转换后的值的网页的页面源。这需要包含 httpQuery 库

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

有显然有更彻底(和复杂)的方法来解决这个问题,但这至少以最小的努力解决了它。

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.

百思不得你姐 2024-09-02 02:27:05

快速而简单的答案是使用 Firefox 插件。有许多货币转换器可用作附加组件,但我最终使用了 Exch,因为它最适合我的需求。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文