File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 99# dependencies = [
1010# "httpx",
1111# "lxml",
12+ # "requests_html",
1213# ]
1314# ///
1415
1516from typing import NamedTuple
1617
1718import httpx
1819from lxml import html
20+ from requests_html import HTMLSession
1921
2022
2123class CovidData (NamedTuple ):
@@ -26,11 +28,17 @@ class CovidData(NamedTuple):
2628
2729def covid_stats (url : str = "https://www.worldometers.info/coronavirus/" ) -> CovidData :
2830 xpath_str = '//div[@class = "maincounter-number"]/span/text()'
31+ session = HTMLSession ()
32+ r = session .get (url )
33+ print (r .html .html )
34+ r .html .render ()
35+ print (r .html .html )
2936 return CovidData (
3037 * html .fromstring (httpx .get (url , timeout = 10 ).content ).xpath (xpath_str )
3138 )
3239
3340
41+
3442fmt = """Total COVID-19 cases in the world: {}
3543Total deaths due to COVID-19 in the world: {}
3644Total COVID-19 patients recovered in the world: {}"""
You can’t perform that action at this time.
0 commit comments