Skip to content

Commit

Permalink
New Project
Browse files Browse the repository at this point in the history
  • Loading branch information
AKmahim committed Apr 5, 2020
1 parent 2a7922a commit 27bfa69
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Coronavirus_update_through_WhatApps/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""This code is written by AKmahim"""

import re
import requests
import sys


def find_case(url):
#this take a the url and collect the data about world coronavirus case return 3 data-world_case,death_case,recovered_case
resp = requests.get(url)
if resp.ok is False:
sys.exit("Could not connect with website")
else:
content = resp.text
WC = re.findall(total_pat,content)
DC = re.findall(death_pat,content)
RC = re.findall(recover_pat,content)

return WC[0],DC[0],RC[0]







if __name__ == "__main__":
total_pat = re.compile(r'<div class="maincounter-number">\s+<span style="color:#aaa">(.*?) </span>\s+</div>')
death_pat = re.compile(r'<div class="maincounter-number">\s+<span>(.*?)</span>\s+</div>')
recover_pat =re.compile(r'<div class="maincounter-number" style="color:#8ACA2B ">\s+<span>(.*?)</span>\s+</div>')
world_url = "https://www.worldometers.info/coronavirus/#countries"
bd_url = "https://www.worldometers.info/coronavirus/country/bangladesh/"
tc1,dc1,rc1 = find_case(world_url)
tc2,dc2,rc2 = find_case(bd_url)

res1 = "World Case---\nCoronavirus Cases: {}\nDeaths: {}\nRecovered: {}\n".format(tc1,dc1,rc1)
res2 = "Bangladesh Case--\nCoronavirus Cases: {}\nDeaths: {}\nRecovered: {}".format(tc2,dc2,rc2)
print(res1) #world case
print(res2) #bangladesh case


0 comments on commit 27bfa69

Please sign in to comment.