1

Thank you for the helpers !

I am scraping a table of data about covid19 and push it into a pandas data frame , it was working until this morning .

That the code :

import pandas as pd
import requests
from bs4 import BeautifulSoup


url = 'https://www.worldometers.info/coronavirus/'

req = requests.get(url)

page = BeautifulSoup(req.content, 'html.parser')

table = page.find_all('table',id="main_table_countries_today")[0]

print(table)

df = pd.read_html(str(table))[0]

This morning I starting to get the next error :

ValueError: No tables found matching pattern '.+'

Can you please help me figure it out ?

10
  • 1
    This code is working fine for me. Returning a list of dataframes. Commented May 29, 2020 at 11:29
  • I am getting the same error on different ide , can you please show me what you get from the code ? Commented May 29, 2020 at 11:33
  • Install covid19 library. It is better pip install COVID19Py https://pypi.org/project/COVID19Py/ Commented May 29, 2020 at 11:35
  • @ZurHanin - Not sure whats the issue. Can you check the lib versions for lxml and html5lib, once? Commented May 29, 2020 at 11:38
  • Thank You ,your api is a really good source , but its importune to me to understand what i did wrong in my code .. Commented May 29, 2020 at 11:39

1 Answer 1

3

Try changing the last line to: df = pd.read_html(str(table), displayed_only=False)[0] The table header at the url has changed its style attribute to style="width:100%;margin-top: 0px !important;display:none;". Previously it did not have the 'display' tag set.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very very much , your solution work ! can you please guide me on which subject i can read for deep understanding about that subject ?
Pandas read_html simply provides the option of processing elements with display:none set (see pandas.pydata.org/pandas-docs/stable/reference/api/…). See more on the display property here w3schools.com/css/css_display_visibility.asp. By the way, your original code works again today (May 31), so they changed again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.