您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使用python向RESTful API发出请求

使用python向RESTful API发出请求

使用请求

import requests
url = '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.textresponse.json()(或可能response.status_code先检查)。请参阅此处快速入门文档,尤其是本节

python 2022/1/1 18:18:34 有306人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶