0
我試圖讓手在使用文檔: https://pairbulkdata.uspto.gov/#/api-documentation翻譯捲曲查詢請求
然而,當我想這些查詢,我得到錯誤信息。 我想將curl查詢翻譯成python請求。
curl -i -X POST -H "Content-Type:application/json" -d '{"searchText":"medicine AND diabetes","qf": "patentTitle"}' http://pairbulkdata.uspto.gov/queries
這裏是我想要的Python代碼:
import requests
data = {"searchText":"medicine AND diabetes","qf": "patentTitle"}
url = "http://pairbulkdata.uspto.gov/queries"
header = {"Content-Type":"application/json"}
r = requests.post(url, data = data, headers=header)
,但我得到的錯誤。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">\n<TITLE>ERROR: The request could not be satisfied</TITLE>\n</HEAD><BODY>\n<H1>ERROR</H1>\n<H2>The request could not be satisfied.</H2>\n<HR noshade size="1px">\nBad request.\n<BR clear="all">\n<HR noshade size="1px">\n<PRE>\nGenerated by cloudfront (CloudFront)\nRequest ID: OIhwX7a3zVJq04M_qf0sjWhuke3fHb1-6wFJsN7UX_Rp2w_gzebTGA==\n</PRE>\n<ADDRESS>\n</ADDRESS>\n</BODY></HTML>
當我運行,而不是'curl'命令,我得到的完全相同的輸出。所以,請嘗試修復您的請求。 – Fejs
[Post JSON using Python Requests]可能的重複(http://stackoverflow.com/questions/9733638/post-json-using-python-requests) –
也許他們是服務器的問題。你的文檔中的 – furas