coronabot/world.py

27 lines
600 B
Python
Executable File

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import requests
url='https://www.worldometers.info/coronavirus/'
response = requests.get(url)
web=response.text.split("\n")
total = web[360]
deaths = web[370]
recovered = web[378]
total = total.split(">",1)[1]
deaths = deaths.split(">",1)[1]
recovered = recovered.split(">",1)[1]
total = total.split(" ",1)[0]
deaths = deaths.split("<",1)[0]
recovered = recovered.split("<",1)[0]
outfile = open("world.txt","w")
print("World situation\nTotal coronavirus cases: %s\nTotal deaths: %s\nRecovered people: %s" %(total, deaths, recovered), file=outfile)