I want to extract json content within the html comment tag using BeautifulSoup.
<script data_id ="dfsfre2323" data_key="23424sfsfsfdafd", type="application/json"><!--
{"employee": {"name":"sonoo", "salary":56000, "married":true}}--></script>]
The output should be as follows
Name: sonoo
Salary: 56000
Married: True
I have tried the following:
from bs4 import BeautifulSoup, Comment
import json
soup = BeautifulSoup(webpage, "html.parser")
data = soup.find("script", {"type":"application/json", data_id ="dfsfre2323" data_key="23424sfsfsfdafd"})
comment = soup.find(text=lambda text:isinstance(data, Comment))
I don't get nothing in the comment.
Any help appreciated in advance?