Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Mar 25, 2020
2 parents b2c3f4c + 089406d commit c3de30f
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 35 deletions.
52 changes: 38 additions & 14 deletions display.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<<<<<<< HEAD
#!/usr/bin/python
=======
#!/usr/bin/env python3
>>>>>>> b055c788972f0ba38dd50727d9e75908a0579037

from bs4 import BeautifulSoup
import Adafruit_CharLCD as LCD
import requests
import time
import math
import csv
import sys


# Insert your URL here
url_c = "https://corona.help/country/switzerland"
Expand All @@ -11,6 +20,7 @@
cc = "CH"
population_w = "7770173166"
url_w ="https://corona.help/"
Waiting = '15.0'


#Raspberry Pi configuration:
Expand Down Expand Up @@ -39,41 +49,55 @@
soup_w = BeautifulSoup(page_w.text, 'html.parser')

# print (soup)
infections_c = soup_c.select('h1')[1].text.strip()
deaths_c = soup_c.select('h1')[2].text.strip()
survived_c = soup_c.select('h1')[3].text.strip()

infections_w = soup_w.select('h1')[1].text.strip()
deaths_w = soup_w.select('h1')[2].text.strip()
survived_w = soup_w.select('h1')[3].text.strip()
percent_c = '{:.7f}'.format(int(infections_c) / int(population_c))
percent_w = '{:.7f}'.format(int(infections_w) / int(population_w))
country = soup_c.select('h2')[0].text.strip()
infections_c = soup_c.select('h2')[1].text.strip()
deaths_c = soup_c.select('h2')[2].text.strip()
survived_c = soup_c.select('h2')[3].text.strip()
today_c = soup_c.select('h2')[4].text.strip()

first, last = country.split()

infections_w = soup_w.select('h2')[1].text.strip()
deaths_w = soup_w.select('h2')[2].text.strip()
survived_w = soup_w.select('h2')[3].text.strip()
today_w = soup_w.select('h2')[4].text.strip()

percent_c = str('{:.7f}'.format(int(infections_c.replace(',','')) / int(population_c))+(" %"))
percent_w = str('{:.7f}'.format(int(infections_w.replace(',','')) / int(populatio



lcd.set_color(1.0, 0.54, 0.0)
lcd.clear()
lcd.message(cc + ' Cases ' + infections_c)
lcd.message('\nWW Cases ' + infections_w)

time.sleep(20.0)
time.sleep(Waiting)

lcd.set_color(0.0, 1.0, 0.0)
lcd.clear()
lcd.message(cc + ' Recoverd ' + survived_c)
lcd.message('\nWW ' + survived_w)

time.sleep(20.0)
time.sleep(Waiting)

lcd.set_color(1.0, 0.0, 0.0)
lcd.clear()
lcd.message(cc +' Dead ' + deaths_c)
lcd.message('\nWW Dead ' + deaths_w)

time.sleep(20.0)
time.sleep(Waiting)

lcd.set_color(0.2, 0.5, 0.4)
lcd.clear()
lcd.message('% of Swiss Population')
lcd.message('% of 'first' Population')
lcd.message('\n' + percent_w + '%')

time.sleep(20.0)
time.sleep(Waiting)

lcd.set_color(0.2, 0.5, 0.4)
lcd.clear()
lcd.message('Infected Today in' +cc)
lcd.message('\n' + today_c)

time.sleep(Waiting)
39 changes: 23 additions & 16 deletions fetch.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from bs4 import BeautifulSoup
import requests
import csv
import sys
import time

# Insert your URL here
url_c = "https://corona.help/country/switzerland"
# Insert your Population here
population_c = "8570000"
population_c = "8173166"
population_w = "7770173166"
url_w ="https://corona.help/"

Expand All @@ -13,28 +16,32 @@
page_w = requests.get(url_w)
soup_w = BeautifulSoup(page_w.text, 'html.parser')

# print (soup)
country = soup_c.select('h1')[0].text.strip()
infections_c = soup_c.select('h1')[1].text.strip()
deaths_c = soup_c.select('h1')[2].text.strip()
survived_c = soup_c.select('h1')[3].text.strip()
#print (soup_c)

first, *middle, last = country.split()
country = soup_c.select('h2')[0].text.strip()
infections_c = soup_c.select('h2')[1].text.strip()
deaths_c = soup_c.select('h2')[2].text.strip()
survived_c = soup_c.select('h2')[3].text.strip()
today_c = soup_c.select('h2')[4].text.strip()

infections_w = soup_w.select('h1')[1].text.strip()
deaths_w = soup_w.select('h1')[2].text.strip()
survived_w = soup_w.select('h1')[3].text.strip()
percent_c = str('{:.7f}'.format(int(infections_c) / int(population_c))+(" %"))
percent_w = str('{:.7f}'.format(int(infections_w) / int(population_w))+(" %"))
first, last = country.split()

infections_w = soup_w.select('h2')[1].text.strip()
deaths_w = soup_w.select('h2')[2].text.strip()
survived_w = soup_w.select('h2')[3].text.strip()
today_w = soup_w.select('h2')[4].text.strip()

percent_c = str('{:.7f}'.format(int(infections_c.replace(',','')) / int(population_c))+(" %"))
percent_w = str('{:.7f}'.format(int(infections_w.replace(',','')) / int(population_w))+(" %"))


print("Cases in " +(last))
print("Cases in " +(first))
print(("Infections: ") + infections_c + (", Deaths: ") + deaths_c+(", Survived: ")+survived_c)
print("Numbers Worldwide")
print(("Infections: ")+infections_w+(", Deaths: ")+ deaths_w +(", Survivied: ") +survived_w)
print(("Infections: ")+infections_w+(", Deaths: ")+ deaths_w +(", Survived: ") +survived_w)

print (percent_c + (" of ")+(last)+ (" citicens are infected!"))
print (percent_c + (" of ")+(first)+ (" citicens are infected!"))
print (percent_w + (" of world citicens are infected!"))
print ()
#print ()


18 changes: 18 additions & 0 deletions get_csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/python

import csv
import sys

#input number you want to search
number = input('Enter number to find\n')

#read csv, and split on "," the line
csv_file = csv.reader(open('population.csv', "rt"), delimiter=";")


#loop through csv list
for row in csv_file:
#if current rows 2nd value is equal to input, print that row
if number == row[0]:
print (row[2])
print ("succes")
6 changes: 1 addition & 5 deletions population.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Data Source;World Development Indicators;
;;
Last Updated Date;27.02.2020;
;;
Country Name;Country Code;2018
Country;Country Code;2018
Aruba;ABW;105845
Afghanistan;AFG;37172386
Angola;AGO;30809762
Expand Down

0 comments on commit c3de30f

Please sign in to comment.