P粉5909293922023-08-19 00:31:42
Don't build your own HTML to JSON converter, use an existing converter, such as html-to-json
.
Use pip install html-to-json
After installation, add the following code to your code:
import html_to_json html = "在这里放入你的HTML代码" json = html_to_json.convert(html) print(json)
The way html
the string is generated depends on the source of the HTML: it can be from a file, a URL, etc...