동적 크롤링이 좋은데 동적 시간안에 못해서 정적 

어제 함수를 좀 응용해서 불러왔다 파일 임포트 참조~

import os
import requests
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

from bs4 import BeautifulSoup
from babel.numbers import format_currency
from day5 import play5

os.system("clear")



def comefileday5():
  biglist = play5.firstwork()
  return biglist

def finding(biglist):  
  country = input("#: ")
  if country.isdecimal():
    number = int(country)
    if number <= len(biglist):
      print(biglist[number][1])
      return number
    else:
      print("Choose a number from the list.")
      return finding(biglist)
  else:
    print("That wasn\'t a number.")
    return finding(biglist)

def money(papper1,papper2):  
  print(f"\nHow many {papper1} do you want to convert to {papper2}?")
  moneyback = input()
  if moneyback.isdecimal():
    number = int(moneyback)
    return number
  else:
    print("That wasn\'t a number.")
    return money(papper1,papper2)

  

def extractmoney(money1, money2, mymoney):
  result = requests.get(f"https://transferwise.com/gb/currency-converter/{money1}-to-{money2}-rate?amount={mymoney}")
  soup = BeautifulSoup(result.text,"html.parser")
  change = soup.find_all('input',{"id":"rate"})
  
  listdata = []

  for form in change:
    listdata.append(form)
  listsimple=str(listdata[0]).split()
  for i in listsimple:
    if 'value' == i[0:5]:
      moneychange = float(i[7:-3])
      done = float(mymoney)*moneychange
      print(format_currency(float(mymoney), money1.upper(), locale="ko_KR"),end= '')
      print(' is ',end='')
      print(format_currency(done, money2.upper(), locale="ko_KR"))

  



def startgame():  
  print("Welcome to CurrencyConvert PRO 2000")
  biglist = comefileday5()
  print("\nWhere are you from? Choose a country by number.\n")
  country_num1 = biglist[finding(biglist)][3]
  print("\nNow choose another country.\n")
  country_num2 = biglist[finding(biglist)][3]
  mymoneyback = money(country_num1.upper(),country_num2.upper())
  extractmoney(country_num1.lower(),country_num2.lower(),mymoneyback)


"""
Use the 'format_currency' function to format the output of the conversion
format_currency(AMOUNT, CURRENCY_CODE, locale="ko_KR" (no need to change this one))


print(format_currency(5000, "KRW", locale="ko_KR"))
"""

 

다음첼린지할때 이쁘게 해야징~

블로그 이미지

Or71nH

,