尝试通过 python(请求模块)获取请求使用有效 API 密钥从 Etherscan API 收集数据时。我没有收到预期的数据,而是看到了 CloudFlare CAPTCHA 页面的 html src 代码。(我不希望官方 API 会发生这种情况)。
with requests.Session() as s:
url = "https://api-ropsten.etherscan.io/api?module=account&action=txlist&address=0xbd90cA199FB00579d87d0536b8389953dF035830&startblock=0&endblock=99999999&page=1&offset=1000&sort=asc&apikey=MyApiKey"
print(s.get(url).text)
响应负责人:(我自己访问 API URL,我不反对这条消息,这显然是防止网络爬虫的重点,但在这种情况下不应触发 CloudFlare):
<title>Attention Required! | Cloudflare</title>
<meta name="captcha-bypass" id="captcha-bypass" />
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]-->
<style type="text/css">body{margin:0;padding:0}</style>