| 9 | |
| 10 | |
| 11 | def getVal(cont1, cont2): |
| 12 | # Extract currency codes from user input (format assumed like "USD- United States Dollar") |
| 13 | cont1val = cont1.split("-")[1] |
| 14 | cont2val = cont2.split("-")[1] |
| 15 | url = f"https://free.currconv.com/api/v7/convert?q={cont1val}_{cont2val}&compact=ultra&apiKey=b43a653672c4a94c4c26" |
| 16 | r = httpx.get(url) |
| 17 | htmlContent = r.content |
| 18 | soup = BeautifulSoup(htmlContent, "html.parser") |
| 19 | try: |
| 20 | # Extract the numeric value from the response text |
| 21 | valCurr = float(soup.get_text().split(":")[1].removesuffix("}")) # {USD:70.00} |
| 22 | except Exception: |
| 23 | print("Server down.") |
| 24 | exit() |
| 25 | return valCurr |
| 26 | |
| 27 | |
| 28 | app = QtWidgets.QApplication([]) |