1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

コメントスパムを退けるフォームのワンライナーアイデア

Posted at

フォームを設置すると、アクセスの少ないページでもわりとコメントスパムの餌食になります。

<form method="POST" action="https://somewhere.com/form">
  メールアドレス <input type="email" name="email">
  <button type="submit">送信</button>
</form>

reCAPTCHA を使えば手軽で安心ですが、それすらも面倒くさいときのネタ半分なアイデアです。

<form method="POST"
    action="https://localhost"
    data-foo="https://somewhere.com/form"
    onsubmit="if(confirm('「キャンセル」を押してください。スパム対策です。')) { return false; } else { this.action = this.getAttribute('data-foo'); return true; }"
>
  メールアドレス <input type="email" name="email">
  <button type="submit">送信</button>
</form>

まず、本来の送信先actiondata-fooなどに記述し、actionhttps://localhostなどのダミーにします。

これでDOMレベルでスクレイピングしてくるボットにはほぼ対策できます。

親切に https://www.cia.gov/ とかに送らせてもいいかもですね! (冗談ですが)

次にonsubmitで、確認ダイアログを表示し、人間殿には敢えてキャンセルを選んでもらいます。

キャンセルが選ばれると、actiondata-fooの値(本来の送信先)を移し、return trueでフォームの内容を送信します。

実は**「フォームの内容を送信します。よろしいですか?」** と、お決まりのワンクッション挟んでいても、それを突破してくるスパムボットがありました。それで逆にする発想に繋がりました。

認知的負荷が高く、コンバージョン率を落としてしまいますが、ブラウザの挙動を再現するタイプのボットにはこれでさらに対策できます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?