Skip to content
Advertisement

convert website table to pandas df (beautifulsoup doesn’t recognize table)

I want to convert a website table to pandas df, but BeautifulSoup doesn’t recognize the table (snipped image below). Below is the code I tried with no luck.

enter image description here

JavaScript

I also tried the code below with no luck

JavaScript

Advertisement

Answer

Your table is not in the <table> tag but in multiple <span> tags.

You can parse these to a dataframe like so:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement