-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_salary.py
66 lines (52 loc) · 1.72 KB
/
check_salary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import requests
import json
import datetime
from bs4 import BeautifulSoup
def get_salary(input_salary):
ret = get_response_salary(input_salary)
json_ret = json.loads(ret.content)
return json_ret['quoteData']['destinationAmount']
def get_response_salary(input_salary):
url = "https://ya5w5myk2j.execute-api.us-east-1.amazonaws.com/prod/quote/external?originRoute=134&destinationRoute=86&amount=" + input_salary + "&way=origin"
ret = requests.get(url)
return ret
def convert_salary(salary):
float_salary = float(salary)
converted_salary = '${:,.2f}'.format(float_salary)
return converted_salary
def get_dolar_blue():
url = "https://www.dolarhoy.com/cotizaciondolarblue"
ret = requests.get(url)
html_doc = ret.text
soup = BeautifulSoup(html_doc, 'html.parser')
info = soup.find_all("span", {"class": "pull-right"})
lista_dolar = []
for inpu in info:
dolar = inpu.contents[0]
lista_dolar.append(dolar)
return lista_dolar
def get_dolar_oficial():
url = "https://www.dolarhoy.com/"
ret = requests.get(url)
html_doc = ret.text
soup = BeautifulSoup(html_doc, 'html.parser')
info = soup.find_all("td", {"class": "number"})
lista_dolar = []
cont = 0
for inpu in info:
if cont < 2:
dolar = inpu.contents[0]
lista_dolar.append(dolar)
cont += 1
else:
break
return lista_dolar
def get_all_dolars():
lista_dolar_oficial = get_dolar_oficial()
lista_dolar_blue = get_dolar_blue()
for dolar in lista_dolar_blue:
lista_dolar_oficial.append(dolar)
return lista_dolar_oficial
if __name__ == '__main__':
salary = get_salary("550000")
convert_salary(salary)