【发布时间】:2016-11-14 12:28:40
【问题描述】:
我正在使用对 https://dandelion.eu/ 的 API 调用进行实体提取。我正在发送文本文件并自动返回一个 json 文件作为响应。这不是我第一次使用这项服务,而且效果非常好。现在我开始使用我一直使用的相同参数发送一组新的文本文件,但我得到了这个:ValueError:解包的值太多。 这是我的代码:
values={"text":" ",
"min_confidence":"0.6",
"include":"types",
"include":"abstract",
"include":"categories"
}
headers = {'X-Target-URI':'https://api.dandelion.eu',
'Host':'api.dandelion.eu',
'Connection': 'keep-alive',
'Server': 'Apache-Coyote/1.1',
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
}
for roots, dirs, files in os.walk(spath): #spath is specified
for file in files:
if file.startswith("A0"):
with open(file, "r") as f:
text = f.read()
values["text"]= " ".join(text.split())
#api call
url = "https://api.dandelion.eu/datatxt/nex/v1/"
data = urllib.urlencode(values, "utf-8")
response = requests.request("POST", url, data=data, headers=headers, params=token_api)
content = response.json()
print content
ErrorValue:解压的值太多
有人可以帮我解决这个问题吗?我总是对其他 api 调用使用相同的代码,并且效果很好。我不知道现在出了什么问题。
【问题讨论】:
标签: python-2.7 api request