我試圖做一個HTTP請求使用tornado.httpclient
一個JSON API像https://api.github.com
,我發現它總是被禁止的403簡單的未授權的請求到Github的API
響應簡化,我讓CLI使用的要求:
$ python -m tornado.httpclient https://api.github.com
得到一個tornado.httpclient.HTTPError: HTTP 403: Forbidden
。
另一方面,如果我嘗試通過瀏覽器或簡單的$ curl https://api.github.com
請求此URL,則響應爲200 OK並顯示正確的JSON文件。
這是什麼造成的?我是否應該在tornado.httpclient
請求中設置一些特定的標題?請求curl
有什麼區別?