开发者

How to block bots in a download script

I created a download script which makes users wait five seconds before the downlaod starts automatically and also counts downloa开发者_如何学Cds. It's very simple. Now I need to find a way to block bots because I want the downlod count to be as realistic as possible, meaning I want it to count only users actually downloading and not bots. Is there a bots list somewhere or just a way to do what I have to? Thanks.


Normal "bots" aren't able to run javascript, so they can't wait (download it).

You can add capcha if you're afraid there are bots with knowledge of "javascript"


Well-behaved robots should respect robots.txt, which allows you to instruct robots how they are allowed to crawl your website.

You cannot reliably block non-well-behaved robots (sort of attempts at human detection such as captcha, as others have suggested). Even though many robots set a special user agent (you can see examples here), a robot can set the user agent to anything it wants to.


Use a captcha. I would suggest you to use Recaptcha.


There are various methods that you could use to get rid of a bot, but they'll also filter out some real users:

  • Only allow clients that send an acceptable User-Agent string.
  • Only allow clients that have JavaScript enabled.
  • Only allow clients that have cookies enabled.
  • Only allow clients that uncheck a checkbox that says, "I'm a robot."
  • Only allow clients that don't fill out a honeypot text input.
  • Have a CAPTCHA (this is used by webmasters who hate their users and have no respect for them; only suggested for sadists and jerks)

You can pick and choose, or combine them to create your own flavor of robot discrimination.


Honeypot fields and timestamp analysis.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜