我正在尝试使用带有请求的Python3从zoho creator API获取数据。尽管我用python做过一些临时工作和数据处理,但我对http请求一无所知。有没有人能帮我把下面的html代码翻译成使用请求的等效python代码?
<form method="GET" action="https://creator.zoho.com/api/xml/sample/view/Employee_View">
<input type="hidden" name ="authtoken" value="************">
<input type="hidden" name ="zc_ownername" value="********">
<input type="hidden" name="criteria" value='(PacienteSL=="Abilio Alfredo Finotti")'>
<input type="hidden" name ="scope" id="scope" value="creatorapi">
<input type="submit" value="View Records">
</form>发布于 2019-09-11 04:25:40
我已经成功地使用urllib的请求来进行这种类型的调用-下面这样的东西应该可以翻译上面的html。
import requests
import urllib
param = urllib.parse.urlencode({"authtoken":"token_here",
"scope":"creatorapi",
"zc_ownername":"owner_here",
"criteria":'(PacienteSL=="Abilio Alfredo Finotti")'})
url = "https://creator.zoho.com/api/xml/{0}/view/{1}/{2}".format("sample", "Employee_View", param)
requests.get(url).content发布于 2020-03-17 07:14:19
不需要urllib,requests会为你处理它:
import requests
url = "https://creator.zoho.com/api/xml/sample/view/Employee_View/"
params = {
"authtoken": "***",
"scope": "creatorapi",
"zc_ownername": "***",
"criteria": "(PacienteSL==\"Abilio Alfredo Finotti\")"
}
requests.get(url, params=params).contenthttps://stackoverflow.com/questions/57762017
复制相似问题