Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 28th, 2020 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. from bs4 import BeautifulSoup
  3.  
  4.  
  5. page = requests.get("https://www.worldometers.info/coronavirus/#countries")
  6. soup = BeautifulSoup(page.content, 'html.parser')
  7. results = soup.find(id='main_table_countries_today')
  8.  
  9. count_table = soup.find('table')
  10. table_rows = count_table.find_all('tr')
  11.  
  12. countries = {}
  13.  
  14. for tr in table_rows:
  15.   td = tr.find_all('td')
  16.   row = [cell.text.strip() for cell in td]
  17.   res = [val for idx, val in enumerate(row)
  18.     if val or (not val and row[idx-1])]
  19.  
  20.   if len(res) > 0 :
  21.     countries[res[0]] = res
  22.  
  23.  
  24. countries_data = {}
  25.  
  26. for key in countries.keys() :
  27.   if key == "MS Zaandam" :
  28.     print(countries[key])
  29.     countries_data[key] = {
  30.     'total cases': countries[key][1],
  31.     'new-cases': countries[key][2],
  32.     'total deaths': countries[key][3],
  33.     'new-deaths': countries[key][4],
  34.     'total-recovered': countries[key][5],
  35.     }
  36.   else :
  37.     countries_data[key] = {
  38.     'total cases': countries[key][1],
  39.     'new-cases': countries[key][2],
  40.     'total deaths': countries[key][3],
  41.     'new-deaths': countries[key][4],
  42.     'total-recovered': countries[key][5],
  43.     'active-cases': countries[key][6],  
  44.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top