【发布时间】:2021-01-07 10:15:50
【问题描述】:
我正在尝试从 JSON 数据中获取 matchID,但是,它低于 TypeError。有人可以在这里建议解决方案吗?
网址:https://bet.hkjc.com/football/getJSON.aspx?jsontype=schedule.aspx
from selenium import webdriver
import requests
import json
match_day_url = 'https://bet.hkjc.com/football/getJSON.aspx?jsontype=schedule.aspx'
driver = webdriver.Chrome(options=options,executable_path=r"XXXXXX")
driver.get(match_day_url)
time.sleep(3)
#print(driver.page_source,'lxml')
pre = driver.find_element_by_tag_name("pre").text
data = json.loads(pre)
matchID = data['matchID']
print (matchID)
错误: TypeError: 列表索引必须是整数或切片,而不是 str
提前致谢。
【问题讨论】: