Hello I am writing this simple program to get the current value of the USD. I am using two methods, one is a simple API call and the other one is web scraping. Now, I would like to show this information on a html file. any idea on how to? here are 2 of the python files i am working with: this one uses API call:
import requests
import json
# Dolar today
dtUrl = 'https://s3.amazonaws.com/dolartoday/data.json'
def dolartoday():
response = requests.get(dtUrl)
format = response.json()["USD"]["transferencia"]
print("DolarToday:", format)
dolartoday()
And this one uses web scraping:
import requests
from bs4 import BeautifulSoup
# airtm
airtmUrl = 'https://rates.airtm.com/'
def airtm():
req = requests.get(airtmUrl)
soup = BeautifulSoup(req.content, 'html.parser')
rates = soup.findAll('div', class_="text-6xl")
for rate in rates:
rate.find('span', class_='rate--general')
print("AirTM:", rate.text)
airtm()
here is the HTML file (is empty):
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
I am using python 3 and HTML 5
DolarToday: {}
AirTM: {}
'; a = '42.00'; b = '36.00'; print(template.format(a, b))` -- see https://docs.python.org/3/library/string.html#string.Formatter.format – Oct 13 '20 at 16:53