Advertisement
Guest User

Untitled

a guest
Mar 13th, 2024
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. import os, time, bs4, requests
  2.  
  3. print('Currencies to EGP.\nUpdates every two minutes.\n\n')
  4.  
  5.  
  6. url = 'https://ta3weem.com'
  7. while True:
  8. 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'})
  9. webPage.raise_for_status()
  10.  
  11. soup = bs4.BeautifulSoup(webPage.text, 'html.parser')
  12. times = soup.select('#usd_table > tbody > tr:nth-child(1) > td.text-center')
  13.  
  14. 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')
  15. euro = soup.select('body > div.container > div.jumbotron > div > div:nth-child(3) > div > div.panel-heading > div > h1')
  16. gbp = soup.select('body > div.container > div.jumbotron > div > div:nth-child(5) > div > div.panel-heading > div > h1')
  17. saudi = soup.select('body > div.container > div.jumbotron > div > div:nth-child(7) > div > div.panel-heading > div > h1')
  18. uae = soup.select('body > div.container > div.jumbotron > div > div:nth-child(9) > div > div.panel-heading > div > h1')
  19.  
  20. usd = str(usd)
  21. euro = str(euro)
  22. gbp = str(gbp)
  23. saudi = str(saudi)
  24. uae = str(uae)
  25. times = str(times)
  26.  
  27. usd = usd.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
  28. euro = euro.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
  29. gbp = gbp.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
  30. saudi = saudi.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
  31. uae = uae.replace("<h1>", "").replace("</h1>", "").replace("[", "").replace("]", "")
  32. times = times.replace('[<td class="text-center" dir="ltr">', "").replace('</td>]', "")
  33. print(times)
  34. print('Official Bank Rate:\n')
  35. print(f'USD To EGP: {usd} EGP')
  36. print(f'Euro To EGP: {euro} EGP')
  37. print(f'GBP To EGP: {gbp} EGP')
  38. print(f'Saudi Riyal To EGP: {saudi} EGP')
  39. print(f'UAE Dirham To EGP: {uae} EGP\n\n')
  40.  
  41. url2 = 'https://egcurrency.com/en/currency/egp/exchange'
  42. 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'})
  43. webPage2.raise_for_status()
  44.  
  45. soup = bs4.BeautifulSoup(webPage2.text, 'html.parser')
  46. 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)')
  47. 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)')
  48. 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)')
  49. 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)')
  50. 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)')
  51.  
  52.  
  53. blackUsd = str(blackUsd)
  54. blackEuro = str(blackEuro)
  55. blackGbp = str(blackGbp)
  56. blackSaudi = str(blackSaudi)
  57. blackUae = str(blackUae)
  58.  
  59. blackUsd = blackUsd.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
  60. blackEuro = blackEuro.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
  61. blackGbp = blackGbp.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
  62. blackSaudi = blackSaudi.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
  63. blackUae = blackUae.replace('[<td class="text-danger">', '').replace("</td>]", "").replace('[<td class="text-success">', "")
  64.  
  65.  
  66. print('Black Market Rate:\n')
  67. print(f'USD To EGP: {blackUsd} EGP')
  68. print(f'Euro To EGP: {blackEuro} EGP')
  69. print(f'GBP To EGP: {blackGbp} EGP')
  70. print(f'Saudi Riyal To EGP: {blackSaudi} EGP')
  71. print(f'UAE Dirham To EGP: {blackUae} EGP\n\n')
  72.  
  73. print("Difference Between Bank & Black Market:\n")
  74.  
  75. usdDif = float(blackUsd)-float(usd)
  76. euroDif = float(blackEuro)-float(euro)
  77. gbpDif = float(blackGbp)-float(gbp)
  78. saudiDif = float(blackSaudi)-float(saudi)
  79. uaeDif = float(blackUae)-float(uae)
  80.  
  81. print(f"USD: {round(usdDif, 2)} EGP")
  82. print(f"Euro: {round(euroDif, 2)} EGP")
  83. print(f"GBP: {round(gbpDif, 2)} EGP")
  84. print(f"Saudi Riyal: {round(saudiDif, 2)} EGP")
  85. print(f"UAE Dirham: {round(uaeDif, 2)} EGP")
  86.  
  87.  
  88.  
  89. time.sleep(120)
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement