Skip to content Skip to sidebar Skip to footer

How To Obtain Currency Rates From This Website Converter Widget Python

How can I implement the currency rates on this website and keep the currencies up to date so that i can access them in python from this website and input and output values and curr

Solution 1:

You can use the following code where exchange_rates is a dict mapping currencies to their rates (the url is the one that this page uses to load it's data)

import requests
import json

url = "https://api.travelex.net/salt/config/multi?key=Travelex&site=%2Fvirgin&options=abhikzl"
r = requests.get(url)
data = json.loads(r.text)
exchange_rates = data['rates']['rates']

for item in exchange_rates:
    print("{}, {}".format(item, exchange_rates[item]))

You can apply this to most sites by loading them with the chrome developer network window open and look through the requests to find the one that loads in this data.

Post a Comment for "How To Obtain Currency Rates From This Website Converter Widget Python"