import json
import requests
from bs4 import BeautifulSoup
url = 'https://play.google.com/store/apps/details?id=shooter.online.warplanes&hl=en'
data = requests.get(url)
soup = BeautifulSoup(data.text, 'html.parser')
script = soup.find('script', type='application/ld+json')
dt=json.loads(script.get_text())
错误:文件“C:\Users\Admin\anaconda3\lib\json\decoder.py”,第 355 行,raw_decode 引发 JSONDecodeError("Expecting value", s, err.value) from None JSONDecodeError: Expecting value
这是你如何做到的:
import json
import requests
from bs4 import BeautifulSoup
url = 'https://play.google.com/store/apps/details?id=shooter.online.warplanes&hl=en'
script = BeautifulSoup(requests.get(url).text, 'html.parser').find('script', type='application/ld+json')
print(json.loads(script.string)["name"])
输出:
Sky Combat: war planes online simulator PVP
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句