JavaScript for Uncrawlable Questions

  One way to do this is by using JavaScript to dynamically generate the content of the questionnaire questions, instead of including them directly in the HTML markup. This can prevent web crawlers from easily accessing the content of the questions.

  Another way is to use a CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) system that requires users to prove they are human before accessing the questionnaire questions. This can effectively prevent web crawlers from accessing the content of the questions.

  However, it is important to note that making the questionnaire questions uncrawlable may not be a foolproof solution, as determined attackers may still find ways to access the content through various means.

  There are a few different ways to make questionnaire questions uncrawlable in the code of a web page. Here are two examples:

  1. Using JavaScript to generate the questions dynamically:

    <!-- HTML code for a placeholder div for the questionnaire -->
    <div id="questionnaire"></div>
    
    <!-- JavaScript code to generate the questionnaire questions dynamically -->
    <script>
      // Array of questionnaire questions
      var questions = ["Question 1", "Question 2", "Question 3"];
      
      // Generate HTML markup for each question
      for (var i = 0; i < questions.length; i++) {
        var questionHTML = '<div class="question">' + questions[i] + '</div>';
        document.getElementById("questionnaire").innerHTML += questionHTML;
      }
    </script>
    
    

  In this example, the HTML markup for the questionnaire is simply an empty div with an id of “questionnaire”. The JavaScript code then generates the content of the questionnaire questions by looping through an array of question strings and creating HTML markup for each question using the document.getElementById().innerHTML method. This can make it more difficult for web crawlers to access the content of the questions because they are not included directly in the HTML markup.

  1. Using a CAPTCHA system to prevent web crawlers from accessing the questions:

    <!-- HTML code for a CAPTCHA system and the questionnaire -->
    <div class="captcha">
      <!-- CAPTCHA system code -->
    </div>
    <div class="questionnaire">
      <!-- Questionnaire questions -->
    </div>
    
    <!-- JavaScript code to hide the questionnaire until the CAPTCHA is solved -->
    <script>
      // Hide the questionnaire initially
      document.querySelector(".questionnaire").style.display = "none";
      
      // Show the questionnaire once the CAPTCHA is solved
      function showQuestionnaire() {
        document.querySelector(".captcha").style.display = "none";
        document.querySelector(".questionnaire").style.display = "block";
      }
    </script>
    
    

  In this example, the HTML markup for the web page includes a CAPTCHA system and a separate div for the questionnaire questions. The JavaScript code initially hides the questionnaire using the style.display property, and defines a function to show the questionnaire once the CAPTCHA is solved. This can prevent web crawlers from accessing the content of the questions until the user proves they are human by solving the CAPTCHA.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值