Why is Poloniex API blocked by CAPTCHA? Expected JSON, but response is HTML

萝らか妹 提交于 2019-12-06 10:31:30

问题


I am using the following code to look up json from the poloniex API. It is returning HTML instead of JSON. What am I doing wrong? I would like JSON.

import requests
res = requests.get("https://poloniex.com/public?command=returnTradeHistory&currencyPair=BTC_NXT&start=1410158341&end=1410499372")
print(res.text)

回答1:


To summarize the comment chain, you are almost certainly doing something that the server doesn't like which causes it to ask you for a CAPTCHA.

One of the commenters pointed out the documented limit of "6 calls per second to the public API, or repeatedly and needlessly fetching excessive amounts of data". We can only guess at what "repeatedly" or "needlessly" mean to the service, but I think you've made it at least suspicious because it is asking (via CAPTCHA) "are you a person or a program?".

If you want to know what the service's actual limits are, contact the firm. You might have to pay to get the data you are looking for.




回答2:


Thanks to a comment of user Mehul, I solved the same problem, but using PHP. I was trying for 2 hours to make a simple curl() to retrieve the public api using this simple call:

https://poloniex.com/public?command=returnTicker

The problem for me was that I was trying to do the call from my local server (at home). So thanks to Mehul, I decided to test to upload the script to my server and voilà: it immediately ran as expected, returning the json array.

My server is in the USA, although I'm in Mexico. Maybe there will be a problem of IPs and geolocalizations. Or a problem "home" vs. "server" connection. I don't know, but I hope that my approach was useful to other people. I really had problems to find some help with this issue. Ep, and I've implemented some API integrations with other exchanges!



来源:https://stackoverflow.com/questions/47957480/why-is-poloniex-api-blocked-by-captcha-expected-json-but-response-is-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!