且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将curl查询转换为请求

更新时间:2022-06-13 22:35:52

尝试使用可以将 curl 转换为请求 的转换器p>

http://curl.trillworks.com/

http://curl.trillworks.com/

https://shibukawa.github .io / curl_as_dsl / index.html

编辑:

我检查了文档,并且有指向使用API​​获取数据的页面的链接

I checked documentation and there is link to page which uses API to get data

https://pairbulkdata.uspto.gov/#/search?q=medicine %20AND%20diabetes& sort = applId%20asc

似乎它在 / api / queries $ c $中使用了url c>,但文档显示 /查询

It seems it uses url with /api/queries but documentations shows /queries

-

此代码为我提供了一些JSON数据-所以可能可行

This code gives me some data as JSON - so probably it works

curl 'https://pairbulkdata.uspto.gov/api/queries' -X POST -H 'Content-Type: application/json' -d '{"searchText":"medicine AND diabetes","qf": "patentTitle"}'

-

这也给出了一些结果。

import requests

url = "https://pairbulkdata.uspto.gov/api/queries"

headers = {"Content-Type":"application/json"}

data = {"searchText":"medicine AND diabetes","qf": "patentTitle"}

r = requests.post(url, json=data, headers=headers)

print(r.text)

我使用


  • https:// 而不是 http://

  • / api / queries 而不是 / queries

  • json = 而不是 data =

  • https:// instead of http://
  • /api/queries instead of /queries
  • json= instead of data=