Skip to content
Advertisement

Convert html table to json with BeautifulSoup

I am trying to convert HTML table to json using beautifulsoup() function python, I was able to convert but the data coming in wrong json format.

JavaScript

The above code prints JSON in the below format.

JavaScript

I would like to get it in below format

JavaScript

Some help is appreciated

Advertisement

Answer

The output you want is not a valid format, so you can print it after converting the dict to string and replacing the braces.

Here is the working code:

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