相关疑难解决方法(0)

使用python向RESTful API发出请求

我有一个RESTful API,我使用EC2实例上的Elasticsearch实现来公开内容语料库.我可以通过从终端(MacOSX)运行以下命令来查询搜索:

curl -XGET 'http://ES_search_demo.com/document/record/_search?pretty=true' -d '{
  "query": {
    "bool": {
      "must": [
        {
          "text": {
            "record.document": "SOME_JOURNAL"
          }
        },
        {
          "text": {
            "record.articleTitle": "farmers"
          }
        }
      ],
      "must_not": [],
      "should": []
    }
  },
  "from": 0,
  "size": 50,
  "sort": [],
  "facets": {}
}'
Run Code Online (Sandbox Code Playgroud)

我如何使用python/requestspython/urllib2(不确定要使用哪一个 - 使用urllib2,但听到请求更好......)将上面变成API请求?我是否以标题或其他方式传递?

python api rest elasticsearch

194
推荐指数
4
解决办法
54万
查看次数

标签 统计

api ×1

elasticsearch ×1

python ×1

rest ×1