首页 > 解决方案 > 使用请求库使用 python 从 ZOHO CREATOR API 获取数据

问题描述

我正在尝试使用带有请求的 Python 3从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>

标签: pythonhtmlpython-requestszoho

解决方案


不需要 urllib,请求会为您处理它:

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).content

推荐阅读