Skip to content

Instantly share code, notes, and snippets.

@sagunsh
Created March 31, 2020 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagunsh/28cd1c882d863939962ccab494f131b9 to your computer and use it in GitHub Desktop.
Save sagunsh/28cd1c882d863939962ccab494f131b9 to your computer and use it in GitHub Desktop.
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