How to stop spammers from getting the email addres

2019-04-09 14:31发布

Duplicate:


What is the best way to prevent spammers from getting the email address from your mailto links? I'm under the impression that javascript could be a solution. I don't know if my current solution is fool proof, so that's why I'm asking.

Here's what I'm currently doing:

<script language="JavaScript"><!--
var name = "emailusername";
var domain = "yahoo.com";
var text = "emailusername@yahoo.com";
document.write('<a href=\"mailto:' + name + '@' + domain + '\">');
document.write(text + '</a>');
// --></script>

Is there is a better way? I don't like having to have this chunk of code everywhere I want to put a mailto link.

7条回答
放我归山
3楼-- · 2019-04-09 15:06

That's not even remotely a good way. Spammers will grab the whole thing and match addresses with a regex. They won't bother looking for mailto:. Also, any scheme you can think of with Javascript has already been tought of and countered by the spammer. In fact, they'll probably just be able to run the javascript and get the adress.

You can

A) Filter spam
B) Use a form to submit mail (Which the spammers will still probably use.)

查看更多
劳资没心,怎么记你
4楼-- · 2019-04-09 15:07

Javascript helps, but this won't help much. The email address is still visible in the html source using this type of script.

The "best" options use client-side javascript to "build" the email address out of parts, so the entire email address is never visible in the HTML source in one piece. The browser puts it together for you on the client.

查看更多
兄弟一词,经得起流年.
5楼-- · 2019-04-09 15:08

A simple fix:

<script language="JavaScript"><!--
var name = "emailusername";
var domain = "yahoo.com";
document.write('<a href=\"mailto:' + name + '@' + domain + '\">');
document.write(name + '@' + domain + '</a>');
// --></script>

Which basically is the same as Reed suggests but with you existing code.

查看更多
地球回转人心会变
6楼-- · 2019-04-09 15:18

The best way to prevent harvesting is to simply not have the mailto: link at all.

Short of that, there aren't many counters. Things like CSS content and images have been tried and circumvented, and JavaScript is a half-way non-solution (which is to say it doesn't work.)

One possible counter is obfuscation: Add nonsense to your address like this:

mailNO`at`SPAMyahoo`dot`com

And most automated harvesters will (initially) have some trouble detecting it. Alternatively, things like comments could be used to confuse most harvesters. (RFC822 describes the full syntax of email addresses, which includes comments as a part of the address-specification.)

Another counter is to use a form with a CAPTCHA of some sort.

None of them are fully effective.

查看更多
我命由我不由天
7楼-- · 2019-04-09 15:22

You're on the right track, but having emailusername in there sort of defeats the purpose (most spider bots don't bother to make the distinction between HTML and script code, and just look for anything that appears email-like on the page).

I have heard of evidence that some spider bots have the capability to run Javascript now, and will resolve this sort of obfuscation all by themselves.

查看更多
登录 后发表回答