【发布时间】:2021-07-26 10:23:06
【问题描述】:
大家好,我是这个领域的新手,很抱歉我的无知 我试图制作一个发送http post请求的函数>>获取json响应>>只取'expiresdate'值并保存到变量中以供以后使用。
我尝试做这样的事情:
def getexpiresdate():
lastdiclist = getSettingsFromFile()
WhoApi = lastdiclist['wxakey']
url = f'https://www.whoisxmlapi.com/whoisserver/WhoisService?'
apiurl = f'{url}apiKey={WhoApi}&domainName={askfordomain()}'
r = requests.get(apiurl).json()
results = r.json()
print(results)
getexpiresdate()
我得到了一些错误:
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
如果有人能帮助我理解我如何解析 json 并只提取一个值,我会很高兴。
【问题讨论】:
标签: python python-3.x python-requests