Created
March 31, 2020 14:39
-
-
Save sagunsh/28cd1c882d863939962ccab494f131b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from lxml import html | |
def create_tweet(): | |
response = requests.get('https://www.worldometers.info/coronavirus/') | |
doc = html.fromstring(response.content) | |
total, deaths, recovered = doc.xpath('//div[@class="maincounter-number"]/span/text()') | |
tweet = f'''Coronavirus Latest Updates | |
Total cases: {total} | |
Recovered: {recovered} | |
Deaths: {deaths} | |
Source: https://www.worldometers.info/coronavirus/ | |
#coronavirus #covid19 #coronavirusnews #coronavirusupdates | |
''' | |
return tweet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment