小编fre*_*123的帖子

如何使用漂亮的汤 python 从脚本标签中提取 json?

我想reviewCount使用美丽的汤从脚本标签中提取。尝试了不同的方法,但没有成功。

<script type="application/json" data-initial-state="review-filter">
{"languages":[{"isoCode":"all","displayName":"Toutes les langues","reviewCount":"573"},{"isoCode":"fr","displayName":"français","reviewCount":"567"},{"isoCode":"en","displayName":"English","reviewCount":"6"}],"selectedLanguages":["all"],"selectedStars":null,"selectedLocationId":null}
</script>
Run Code Online (Sandbox Code Playgroud)

html python json beautifulsoup web-scraping

4
推荐指数
1
解决办法
2757
查看次数

如何将字符串列表转换为字典列表?

我必须从字符串列表中生成一个键、值对字典列表。例如,我有一个列表

my_list = ["John","Google","yes","Sara","TCS","no","John","facebook","yes"]

Run Code Online (Sandbox Code Playgroud)

我希望输出如下:


[
{"name":"John","company":"Google","avaiable":"yes"},
{"name":"Sara","company":"TCS","avaiable":"No"},
{"name":"John","company":"facebook","avaiable":"yes"},

]

Run Code Online (Sandbox Code Playgroud)

python string dictionary tuples list

1
推荐指数
1
解决办法
95
查看次数

标签 统计

python ×2

beautifulsoup ×1

dictionary ×1

html ×1

json ×1

list ×1

string ×1

tuples ×1

web-scraping ×1