-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
24 lines (19 loc) · 720 Bytes
/
Copy pathapp.py
File metadata and controls
24 lines (19 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from flask import Flask
from requests import get
from bs4 import BeautifulSoup
def getDollarValue(url):
req = get(url).text
soup = BeautifulSoup(req, 'lxml')
purchaseValue = int(float(soup.select(".value")[0].text.strip('$')))
sellingValue = int(float(soup.select(".value")[1].text.strip('$')))
return {'compra': purchaseValue, 'venta': sellingValue}
app = Flask(__name__)
@app.route('/')
def main():
return 'Hey! Please make a GET request to /official or /blue'
@app.route('/official')
def getOfficial():
return getDollarValue("https://www.dolarhoy.com/cotizaciondolaroficial")
@app.route('/blue')
def getBlue():
return getDollarValue("https://www.dolarhoy.com/cotizaciondolarblue")