gpt4 book ai didi

javascript - REST Api 返回验证码

转载 作者:太空宇宙 更新时间:2023-11-04 01:54:12 48 4
gpt4 key购买 nike

我正在尝试使用 URL https://www.coindesk.com/api/ 来使用比特币价格历史记录其余 Web 服务 ( https://api.coindesk.com/v1/bpi/historical/close.json ) .

当我在浏览器中输入以前的 URL 时,它工作正常,但是当我使用 Node/Express 获取数据然后重新发送它时,下面的代码不起作用,当我使用 Postman 向 m Node/Express 服务器发送 GET 请求时,我在这篇文章的底部得到了 HTML 结果,看起来像验证码:

Node/表达代码:

const express = require('express');
const request = require('request');

const router = express.Router();

router.get('/bitcoinPrices', function(req, res) {
request('https://api.coindesk.com/v1/bpi/historical/close.json', function (error, response, body) {
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
res.send(body);
});
});

module.exports = router;

http://localhost:3000/api/bitcoinPrices 发出 GET 请求后的响应:

<!DOCTYPE html>
<!--[if lt IE 7]>
<html class="no-js ie6 oldie" lang="en-US">
<![endif]-->
<!--[if IE 7]>
<html class="no-js ie7 oldie" lang="en-US">
<![endif]-->
<!--[if IE 8]>
<html class="no-js ie8 oldie" lang="en-US">
<![endif]-->
<!--[if gt IE 8]>
<!-->
<html class="no-js" lang="en-US">
<!--
<![endif]-->
<head>
<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,maximum-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>
<!--[if lte IE 9]>
<script type="text/javascript" src="/cdn-cgi/scripts/jquery.min.js"></script>
<![endif]-->
<!--[if gte IE 10]>
<!-->
<script type="text/javascript" src="/cdn-cgi/scripts/zepto.min.js"></script>
<!--
<![endif]-->
<script type="text/javascript" src="/cdn-cgi/scripts/cf.common.js"></script>
</head>
<body>
<div id="cf-wrapper">
<div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
<div id="cf-error-details" class="cf-error-details-wrapper">
<div class="cf-wrapper cf-header cf-error-overview">
<h1 data-translate="challenge_headline">One more step</h1>
<h2 class="cf-subheadline">
<span data-translate="complete_sec_check">Please complete the security check to access</span> api.coindesk.com
</h2>
</div>
<!-- /.header -->
<div class="cf-section cf-highlight cf-captcha-container">
<div class="cf-wrapper">
<div class="cf-columns two">
<div class="cf-column">
<div class="cf-highlight-inverse cf-form-stacked">
<form class="challenge-form" id="challenge-form" action="/cdn-cgi/l/chk_captcha" method="get">
<script type="text/javascript" src="/cdn-cgi/scripts/cf.challenge.js" data-type="normal" data-ray="3e6fb7629a536938" async data-sitekey="6LfBixYUAAAAABhdHynFUIMA_sa4s-XsJvnjtgB0"></script>
<div class="g-recaptcha"></div>
<noscript id="cf-captcha-bookmark" class="cf-captcha-info">
<div>
<div style="width: 302px">
<div>
<iframe src="https://www.google.com/recaptcha/api/fallback?k=6LfBixYUAAAAABhdHynFUIMA_sa4s-XsJvnjtgB0" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
</div>
<div style="width: 300px; border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none;"></textarea>
<input type="submit" value="Submit"></input>
</div>
</div>
</div>
</noscript>
</form>
</div>
</div>
<div class="cf-column">
<div class="cf-screenshot-container">
<span class="cf-no-screenshot"></span>
</div>
</div>
</div>
<!-- /.columns -->

</div>
</div>
<!-- /.captcha-container -->
<div class="cf-section cf-wrapper">
<div class="cf-columns two">
<div class="cf-column">
<h2 data-translate="why_captcha_headline">Why do I have to complete a CAPTCHA?</h2>
<p data-translate="why_captcha_detail">Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.</p>
</div>
<div class="cf-column">
<h2 data-translate="resolve_captcha_headline">What can I do to prevent this in the future?</h2>
<p data-translate="resolve_captcha_antivirus">If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.</p>
<p data-translate="resolve_captcha_network">If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.</p>
</div>
</div>
</div>
<!-- /.section -->
<div class="cf-error-footer cf-wrapper">
<p>
<span class="cf-footer-item">Cloudflare Ray ID:
<strong>3e6fb7629a536938</strong>
</span>
<span class="cf-footer-separator">&bull;</span>
<span class="cf-footer-item">
<span data-translate="your_ip">Your IP</span>: 46.193.1.145
</span>
<span class="cf-footer-separator">&bull;</span>
<span class="cf-footer-item">
<span data-translate="performance_security_by">Performance &amp; security by</span>
<a data-orig-proto="https" data-orig-ref="www.cloudflare.com/5xx-error-landing?utm_source=error_footer" id="brand_link" target="_blank">Cloudflare</a>
</span>
</p>
</div>
<!-- /.error-footer -->



</div>
<!-- /#cf-error-details -->

</div>
<!-- /#cf-wrapper -->
<script type="text/javascript">
window._cf_translation = {};


</script>
</body>
</html>

最佳答案

我认为你可以使用 jQuery ajax 调用获取信息,然后将其发送到你的 Express 服务器并处理它

$.ajax({
url: "https://api.coindesk.com/v1/bpi/historical/close.json",
})
.done(function( data ) {
alert(data)
});
});

https://jsfiddle.net/egLqh4ja/

关于javascript - REST Api 返回验证码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48590134/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com