本教程展示了如何整合reCaptcha来下载一个文件。这是HTML例子,对所有编程语言都适用。
请注意,这个例子将在更新recaptcha网站的信息后在服务器中运行。
1. 从google recaptcha网站获得网站密钥。请访问下面的链接,了解详细的步骤过程。
https://chillyfacts.com/add-recaptcha-i-m-not-a-robot-in-java-websites/
2.test.html
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("form").submit(function(){
var response = grecaptcha.getResponse();
if(response.length == 0){
alert('Please check the Captcha');
return false;
}
});
});
</script>
<script type="text/javascript">
var onloadCallback = function() {
grecaptcha.render('html_element', {
'sitekey' : 'UPDATE YOUR SITE KEY HERE'
});
};
</script>
</head>
<body>
<h3>Click to download the file</h3>
<form action="http://mykuttywap.in/2013-mp3/dl/load/Malayalam%20Mp3/Malayalam%20(2015)/Maalgudi%20Days/Nepredskazuuye%20Maa.mp3" method="post">
<div id="html_element"></div>
<br>
<input type="submit" value="Download">
</form>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
</script>
</body>
</html>
http://localhost:8080/Test_Rec/test.html