📜  beautifulsoup 从脚本元素中提取 json - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:23.838000             🧑  作者: Mango

代码示例1
import json
from bs4 import BeautifulSoup

html = '''

'''

soup = BeautifulSoup(html, 'html.parser')
res = soup.find('script')
json_object = json.loads(res.contents[0])

for language in json_object['languages']:
    print('{}: {}'.format(language['displayName'], language['reviewCount']))