如何验证机器人是否正在输入信息 [英] How to Verify whether a Robot is Entering Information

查看:94
本文介绍了如何验证机器人是否正在输入信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web表单,用户可以填写该表单,并将信息发送到服务器并存储在数据库中。我担心机器人可能只填写表格,而最终我会得到一个充满无用记录的数据库。如何防止漫游器填写表单?我在想类似Stackoverflow的机器人检测之类的东西,如果它认为您是机器人,它会要求您确认自己不是。

I have a web form which the users fill and the info send to server and stored on a database. I am worried that Robots might just fill in the form and I will end up with a database full of useless records. How can I prevent Robots from filling in my forms? I am thinking maybe something like Stackoverflow's robot detection, where if it thinks you are a robot, it asks you to verify that you are not. Is there a server-side API in Perl, Java or PHP?

推荐答案

有几种解决方案。


  1. 使用验证码。据我所知,SO使用 reCAPTCHA

在表单中添加一个额外的字段,并使用CSS将其隐藏(显示:无)。普通用户不会看到此字段,因此不会填写。您检查提交是否此字段为空。如果不是,那么您正在处理的是一个仔细填写了所有表单字段的机器人。这种技术通常称为蜜罐。

Add an extra field to your form and hide it with CSS (display:none). A normal user would not see this field and therefore will not fill it. You check at the submission if this field is empty. If not, then you are dealing with a robot that has carefully filled out all form fields. This technique is usually referred to as a "honeypot".

添加JavaScript计时器函数。在页面加载时,它的值从零开始,然后随着时间的流逝而增加。普通用户会阅读并填写您的表格一段时间,然后再提交。机器人只会填写表格并在收到表格后立即提交。您检查提交时该值是否与零相差太大。如果有,那么它可能是真实用户。如果您只看到几秒钟(或者由于机器人未执行JavaScript而根本没有值),则可能是机器人。但是,只有在您决定要求用户使用JavaScript才能执行写操作时,此方法才起作用。

Add a JavaScript timer function. At the page load it starts a value at zero and then increases it as time passes. A normal user would read and fill out your form for some time and only then submit it. A robot would just fill out and submit the form immediately upon receiving it. You check if the value has gone much from zero at the submission. If it has, then it is likely a real user. If you see just a couple of seconds (or even no value at all due to the robots not executing JavaScript) then it is likely a robot. This will however only work if you decide you will require your users have JavaScript on in order to perform "write" operations.

还有其他技术可以肯定。但这很简单有效。

There are other techniques for sure. But these are quite simple and effective.

这篇关于如何验证机器人是否正在输入信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆