Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, time, bs4, requests
- print('Currencies to EGP.\nUpdates every two minutes.\n\n')
- url = 'https://ta3weem.com'
- while True:
- webPage = requests.get(url, headers={'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15'})
- webPage.raise_for_status()
- soup = bs4.BeautifulSoup(webPage.text, 'html.parser')
- times = soup.select('#usd_table > tbody > tr:nth-child(1) > td.text-center')
- usd = soup.select('body > div.container > div.jumbotron > div > div.col-xs-12.col-sm-6.col-md-2.col-md-offset-1 > div > div.panel-heading > div > h1')
- euro = soup.select('body > div.container > div.jumbotron > div > div:nth-child(3) > div > div.panel-heading > div > h1')
- gbp = soup.select('body > div.container > div.jumbotron > div > div:nth-child(5) > div > div.panel-heading > div > h1')
- saudi = soup.select('body > div.container > div.jumbotron > div > div:nth-child(7) > div > div.panel-heading > div > h1')
- uae = soup.select('body > div.container > div.jumbotron > div > div:nth-child(9) > div > div.panel-heading > div > h1')
- usd = str(usd)
- euro = str(euro)
- gbp = str(gbp)
- saudi = str(saudi)
- uae = str(uae)
- times = str(times)
- usd = usd.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
- euro = euro.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
- gbp = gbp.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
- saudi = saudi.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
- uae = uae.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
- times = times.replace('[<td class="text-center" dir="ltr">', "").replace('</td>]', "")
- print(times)
- print('Official Bank Rate:\n')
- print(f'USD To EGP: {usd} EGP')
- print(f'Euro To EGP: {euro} EGP')
- print(f'GBP To EGP: {gbp} EGP')
- print(f'Saudi Riyal To EGP: {saudi} EGP')
- print(f'UAE Dirham To EGP: {uae} EGP\n\n')
- url2 = 'https://egcurrency.com/en/currency/egp/exchange'
- webPage2 = requests.get(url2, headers={'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15'})
- webPage2.raise_for_status()
- soup = bs4.BeautifulSoup(webPage2.text, 'html.parser')
- blackUsd = soup.select('body > section:nth-child(3) > div > div > div.col-lg-7.col-md-6 > div > div > table > tbody > tr:nth-child(1) > td:nth-child(3)')
- blackEuro = soup.select('body > section:nth-child(3) > div > div > div.col-lg-7.col-md-6 > div > div > table > tbody > tr:nth-child(3) > td:nth-child(3)')
- blackGbp = soup.select('body > section:nth-child(3) > div > div > div.col-lg-7.col-md-6 > div > div > table > tbody > tr:nth-child(6) > td:nth-child(3)')
- blackSaudi = soup.select('body > section:nth-child(3) > div > div > div.col-lg-7.col-md-6 > div > div > table > tbody > tr:nth-child(2) > td:nth-child(3)')
- blackUae = soup.select('body > section:nth-child(3) > div > div > div.col-lg-7.col-md-6 > div > div > table > tbody > tr:nth-child(4) > td:nth-child(3)')
- blackUsd = str(blackUsd)
- blackEuro = str(blackEuro)
- blackGbp = str(blackGbp)
- blackSaudi = str(blackSaudi)
- blackUae = str(blackUae)
- blackUsd = blackUsd.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
- blackEuro = blackEuro.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
- blackGbp = blackGbp.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
- blackSaudi = blackSaudi.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
- blackUae = blackUae.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
- print('Black Market Rate:\n')
- print(f'USD To EGP: {blackUsd} EGP')
- print(f'Euro To EGP: {blackEuro} EGP')
- print(f'GBP To EGP: {blackGbp} EGP')
- print(f'Saudi Riyal To EGP: {blackSaudi} EGP')
- print(f'UAE Dirham To EGP: {blackUae} EGP\n\n')
- print("Difference Between Bank & Black Market:\n")
- usdDif = float(blackUsd)-float(usd)
- euroDif = float(blackEuro)-float(euro)
- gbpDif = float(blackGbp)-float(gbp)
- saudiDif = float(blackSaudi)-float(saudi)
- uaeDif = float(blackUae)-float(uae)
- print(f"USD: {round(usdDif, 2)} EGP")
- print(f"Euro: {round(euroDif, 2)} EGP")
- print(f"GBP: {round(gbpDif, 2)} EGP")
- print(f"Saudi Riyal: {round(saudiDif, 2)} EGP")
- print(f"UAE Dirham: {round(uaeDif, 2)} EGP")
- time.sleep(120)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement