Guest User

Untitled

a guest
Oct 20th, 2019
117
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. from bs4 import BeautifulSoup
  3.  
  4.  
  5. url = 'https://minfin.com.ua/currency/nbu/'
  6.  
  7. source = requests.get(url)
  8. main_text = source.text
  9. soup = BeautifulSoup(main_text, 'html.parser')
  10. table = soup.find('table', {'class': 'table-auto'})
  11. tr = table.findAll('td', {'class': 'responsive-hide'})
  12.  
  13. money = {'dollar': None,
  14.          'euro': None,
  15.          'rubl': None,
  16.          'zloty': None,
  17.          'frank': None,
  18.          'pound': None}
  19.  
  20. curr = ['dollar','euro', 'rubl','zloty', 'frank','pound']
  21. kurs = []
  22. tupl = None
  23.  
  24. for t in tr:
  25.     kurs.append(t.text[1:8])
  26.  
  27. tupl = [*zip(curr, kurs)]
  28.  
  29. for t in tupl:
  30.     money[t[0]] = t[1]
  31.  
  32. while True:
  33.     vibor = input("Выберите валюту: dollar, euro, rubl, zloty, frank, pound ")
  34.     if vibor == "dollar":
  35.         print("Курс доллара " + str(money['dollar']))
  36.         break
  37.     elif vibor == "euro":
  38.         print("Курс евро" + str(money['euro']))
  39.         break
  40.     elif vibor == "rubl":
  41.         print("Курс рубля " + str(money['rubl']))
  42.         break
  43.     elif vibor == "zloty":
  44.         print("Курс польского злотого " + str(money['zloty']))
  45.         break
  46.     elif vibor == "frank":
  47.         print("Курс швейцарского франка " + str(money['frank']))
  48.         break
  49.     elif vibor == "pound":
  50.         print("Курс английского фунта " + str(money['pound']))
  51.         break
RAW Paste Data