使用python向RESTful API发出请求

使用python向RESTful API发出请求,第1张

使用python向RESTful API发出请求

使用请求:

import requestsurl = 'http://ES_search_demo.com/document/record/_search?pretty=true'data = '''{  "query": {    "bool": {      "must": [        {          "text": { "record.document": "SOME_JOURNAL"          }        },        {          "text": { "record.articleTitle": "farmers"          }        }      ],      "must_not": [],      "should": []    }  },  "from": 0,  "size": 50,  "sort": [],  "facets": {}}'''response = requests.post(url, data=data)

然后,根据您的API返回的响应类型,您可能需要查看

response.text
response.json()
(或可能
response.status_pre
先检查)。请参阅此处的快速入门文档,尤其是本节。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/4973623.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-13
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存