ã¦ã§ãèªåå·¡åããã-bot-ã®ä½ãæ¹ for Perlãåç´ç·¨
ãããããã°æã¯ã¦ãªã®äººåæ¤ç´¢ã§ãã¢ã³ã±ã¼ãã«botã§èªååçãã¦ã奴ãããã¨ãå±
ãªãã¨ãã§è©±é¡ã«ãªã£ããã¨ããã£ãã®ãæãåºãã¦æ¸ãã¦ã¿ããã¯ã¦ãªã¢ã¤ãã¢ã«ãä¸é£ã®é¢é£ã¢ã¤ãã¢ãåºã¦ããã
はてなアイデア
ãããããï¼åçå½ããï¼ptã¨ããã¤ã³ã»ã³ãã£ãã®ä½ãã¨ããå¿ååçè
ã®è³ªã®ä½ãã¨ãããããåé¡ã主ã§ããæ°ããããããã以éã¯botã®åé¡ã«éã£ã¦è¨ãã¨ãCAPTCHAã¿ãããªéãã¥ã¼ãªã³ã°ãã¹ãã®å°å
¥ã¯ãçµå±ã¢ã¯ã»ã·ããªãã£ã¨ãã¬ã¼ããªããã¤ã³ã»ã³ãã£ããå¤ãããä½æ¥éã ãå¢ãã¦ããã©ããããªããããªãåççãä¸ããã¨æãããã®ã§å¤åéå¹æã ããã
ããããããã¥ã¼ãªã³ã°ãã¹ãããã¾ããªãã¦ããé¸æè¢ã®ã©ã¸ãªãã¿ã³ã®é¨åãJavascriptï¼æ¬²ãè¨ãã°Flashï¼ã«ããã ãã§ãããªãbotã®åçãåé¿ã§ããã¨æãã®ã ããå°ãªãã¨ãHTMLãparseãã¦è§£æçµæãå
ã«requestãè¿ãã¿ã¤ãã®botã¯å®å
¨ã«ã·ã£ããã¢ã¦ãã§ããã
ãã¾ãã¨ã«ããã人åæ¤ç´¢ã®ã¢ã³ã±ã¼ãã«èªåæ票ãããbotãªãã¦ãã®ã¯ãå¤å°Perlãããã£ããã¨ã®ãã人ãªãç°¡åã«ä½ãã¦ãã¾ãã®ã ãUserAgentãå½è£
ãã¦ãã¢ã¯ã»ã¹æ¥æãææ©çã«ããã°ãããç°¡åã«ã¯ãã¬ã¯ããªãã ãããï¼ãã¡ããåã¯ãããªãã¨ã¯ããªããï¼ã
ãã»ã¼ãbotä½æã£ã¦ãããªã«ç°¡åã ããã¨ãããã¨ãã¿ããªã«ç¥ã£ã¦ããããã¨ã§ãã»ãã¥ãªãã£å¯¾çã®åèã¨ãéæ³ãªbotã¸ã®å¯¾çãä¿ãäºã«ç¹ããã°ãããªãã¨ãããã¨ã§ãbotä½æè¬åº§ãæ¸ãã¦ã¿ããC++.NETã¨ã使ãã°ãã£ã¨ã¬ãã«ã®é«ãbotï¼ç»é¢ã®ãã¯ã»ã«åä½ã§ã¯ãªãã¯ã管çã§ãããããªãã¤ï¼ãä½ãããã ãããã©ãããã§ã¯ç°¡ä¾¿æ§ã¨å®ç¨æ§ãéè¦ãã¦ActivePerlã使ããbotä½æè¬åº§ã¯ã¨ããããå
¨ï¼ãï¼åãäºå®ãã¦ãã¦ãä½ãæ¹ã使ãæ¹ãå¾ã
ã«ããã¤ãªããã®ã«ãªãäºå®ã
botã§åºæ¥ããã¨
ã»æ¥å¸¸çã«ä½¿ãä¼å¡å¶ãµã¤ãã®èªåãã°ã¤ã³
ã人ã«ãã£ã¦ã¯ãããªãæéç縮ã«ãªããå人ç¨ãã½ã³ã³ã§ããã°ããã¯ãã¼ã¯ã¬ããã®ã»ããç°¡åã§å®ç¨çã ããã·ã§ã«ãã¼ãµã¼ãã£ã³ï¼ãã½ã³ã³ã®ç»é¢ãå¾ãããè¦ãè¾¼ã¾ããï¼ã®ãªã¹ã¯ãå¿é ãªäººã¯ãPerlã§ãã°ã¤ã³ã¹ã¯ãªãããä½ã£ã¦ãã¹ã¯ã¼ããããã¦ããã°ããã ãããèªä½OpenIDçãªãã®ã ã¨æã£ã¦ããã ããã°ã
ã»æ å ±ãµã¤ãããç¹å®ã®æ å ±ãå®æçã«æãåºãã¦è¡¨ç¤º
ãYahoo! Pipesã©ã¤ã¯ãªRSSãã£ã¼ãã®åéã¨åæ§ç¯ãã§ããããããRSSãããªãã¦ãOKãç¹å®ã®idãæã¤divã¿ã°å ãåå¾ã¿ãããªãã¨ãå¯è½ããã¨ãWindowsã®ã¿ã¹ã¯ç®¡çã¨ãUNIXã®cronã¨çµã¿åããã¦ãå®æçã«æéæå®ã§ã³ã³ãã³ããæãåºããã¨ãå¯è½ããã ããã¦ã§ãã§å ¬éããå ´åã¯åéå ã®èä½æ¨©ã¨ãã«æ³¨æã
ã»URLãã¡ã¢ãã®åéãåéããURLã®ç¹å®ã®ã³ã³ãã³ããåé
ãGoogleçã®ãµã¼ãã¨ã³ã¸ã³ã使ã£ã¦ãbotã¨ã»ã¼åãç¨éããããå°è¦æ¨¡ã§ããã°æå¤ã¨ç°¡åãã¹ããã¼ã¯ãã®æ¹æ³ã§ã¡ã¢ããåéãã¦ãã¡ã¼ã«ä¸æéä¿¡ã¹ã¯ãªããï¼ãããç°¡åã«ä½ããï¼ã§ç¡å·®å¥éä¿¡ãã¦ããã¨äºæ³ãããããã®è¾ºãã®ãã¸ãã¯ãå ·ä½çã«ç¥ã£ã¦ãããã¨ã§ãæå¤ãªã¹ãã 対çãæãã¤ããã¨ãã§ãããããããªãã
ã»åä¿¡ããã¡ã¼ã«ããæ½åºããURLã«ã¢ã¯ã»ã¹
ãå¿ç¨ãNet::POP3ãªã©ã®ã¢ã¸ã¥ã¼ã«ã§ã¡ã¼ã«ãåä¿¡ããããããURLçãæ½åºãã¦ãã®ãã¼ã¸ã«èªåã¢ã¯ã»ã¹ãããã¤ãã¤ãå©ç¨æ³ãæãã¤ããªãããã¡ã¼ã«ã¨é£åã§ããã®ãç¥ã£ã¦ããã¨ãããã使ãéãããããã
botã§ã¯åºæ¥ãªããã¨
ã»MMORPGã®ãã¼ã
ã»ã¯ãªãã¯ã¤ã³ã»ã³ãã£ãç³»ãµã¤ãã®èªåå·¡å
ãFlashãJavaãªã©ã使ç¨ãã¦ãããµã¤ãã¯ãä»å説æããæ¹æ³ã§ã¯æä½ã§ããªããã¾ãããã¯ãªãã¯ããã°ãéããããããçãªãµã¤ãã¯å¤§æµJavascriptçã§bot対çãæããã¦ããã®ã§ããããä¸å¯ãè¦ç´éåã ãããã
ç¨æãããã®
ã»Windows XPã®å ¥ã£ããã½ã³ã³
ãããã°ã«ã¡ã©ã¨ãã§Windowsã®å ¥ã£ããã½ã³ã³ã(ry
ã»ActivePerl 5.8.8
ãWindowsã§ã¯Perlãããã©ã«ãã§åãããªãã®ã§ActivePerlã¨ããPerlã¤ã³ã¿ããªã¿ï¼Perlã§æ¸ããããã°ã©ã ãåããã½ããã¿ãããªããï¼ãå°å ¥ãããã¤ã³ã¹ãã¼ã«æ¹æ³ã«ã¤ãã¦ã¯ä¸è¨ã®ãµã¤ãåç §
ãActivePerlのインストール方法 - Windowsでperlを使おう!
ãActivePerlãã¤ã³ã¹ãã¼ã«ããã¨ãæ¡å¼µå.plã®ãã¡ã¤ã«ãActivePerlã®ã¢ã¤ã³ã³ã«ãªããããã«ã¯ãªãã¯ããã¨Perlã¹ã¯ãªããã¨ãã¦å®è¡ã§ããããã«ãªãï¼ActivePerlã®ã¢ã¤ã³ã³ã«ãªããªãæã¯ãã¨ã¯ã¹ããã¼ã©ã®ãã©ã«ããªãã·ã§ã³ã§é¢é£ä»ãã¦ãã ããï¼ããã ããã®æ¹æ³ã ã¨ããã°ã©ã ã®å®è¡ãçµäºããæç¹ã§ã¦ã¤ã³ãã¦ãéãã¦ãã¾ãã®ã§ããã£ããå¦ççµæãè¦ããã¨ãã¯æå¾ã«sleep(10);ãªã©ãæ¸ãå ããå¿
è¦ããããããã§å¦ççµäºå¾ã10ç§éã¦ã£ã³ãã¦ãä¿æãããããã«ãªãã
ãtxtãã¡ã¤ã«ã§ã¹ã¯ãªãããæ¸ããå®æãããæ¡å¼µåãplã«æ¸ãæãã¦å®è¡ï¼ãããã¯æ¡å¼µå.plã®ãã¡ã¤ã«ã¨ãã¦ä½æããå³ã¯ãªãã¯â[ããã°ã©ã ããéã]ããã¨ãã£ã¿ã§ç·¨éï¼ã¨ãã£ãæãããã¡ãããCGIãããªãã®ã§#!user/bin/local/perlã¯ä¸è¦ã
ã»CPANã¢ã¸ã¥ã¼ã«
ãCPANã¨ã¯Perlç¨ã®å
¬éã¢ã¸ã¥ã¼ã«ã©ã¤ãã©ãªã§ãããããããPerlã使ãã»ã¨ãã©ã®äººãPerlã使ãç¶ããæ大ã®çç±ãPerlã§botä½æãç°¡åãªã®ã¯ãbotä½æã«ä¾¿å©ãªããªã¼ã®ã¢ã¸ã¥ã¼ã«ãè±å¯ã«ããã£ã¦ããããã
ãã¥ã¼ããªã¢ã«ï¼æ å ±åéã¹ã¯ãªãã - ãã¯ã¦ãªã¢ã³ãããã©ãã
ãåç´ç·¨ã§ã¯ããã¯ã¦ãªã¢ã³ãããã©ãããã¤ãããç»é²ããURLã®HTMLãåå¾ãã¦ããã¼ã«ã«ã«ä¿åãã¦ããéå»ã®HTMLã¨é£ãéã£ã¦ãããæ´æ°ãç¥ããããã·ã³ãã«ã ããæ£è¦è¡¨ç¾ã¨çµã¿åããããã¨ã«ãããæ ªä¾¡ã¨ãçºæ¿ã¬ã¼ãåå¾ãã¦è§£æããããRSSé
ä¿¡ãã¦ãªããã¥ã¼ã¹ãµã¤ãããç¹å®ã®ã¯ã¼ããå«ãè¨äºã ãæãåºããããããªã©ãå¹
åºãå¿ç¨ãå¯è½ãä½æããbotã®ä½¿ç¨ã«ã¤ãã¦ã¯èªå·±è²¬ä»»ã§ã
LWP::Simpleã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«
ãä»åã¯ãLWP::Simpleã¨ããã¢ã¸ã¥ã¼ã«ã使ç¨ãããããã¯æè¿ã®ActivePerlã«ã¯ããã©ã«ãã§å«ã¾ãã¦ãããããªã®ã§ãuse LWP::Simple;ã¨æ¸ãã¦ã¨ã©ã¼ãåºãªããã°OKãã¨ã©ã¼ãåºããã¤ã³ã¹ãã¼ã«ããï¼ActivePerlä»å±ã®Perl Package Managerããç°¡åã«ã¤ã³ã¹ãã¼ã«ã§ããï¼ãLWP::Simpleã«ã¤ãã¦ã¯ä¸è¨ãµã¤ãåç
§
ãLWP::Simple - simple procedural interface to LWP - metacpan.org
ãLWP::Simpleã®ä½¿ãæ¹ã¯ããã£ã¦ã·ã³ãã«ã
use strict; use Encode; use LWP::Simple; my $content = get("http://d.hatena.ne.jp/heilig_zwei/"); #DOSããã³ãããåããã®ã§shift-jisã«å¤æ Encode::from_to($content, "euc-jp", "shift-jis"); print $content;
ãããã ãã§OKãgetã§æå®ãããµã¤ãã®URLï¼ä¾ã§ã¯å½ãµã¤ãï¼ããHTMLãæ¾ã£ã¦ãã¦ãprintã§è¡¨ç¤ºãããLWP::Simpleã§ä½¿ãã¡ã½ããã¯åºæ¬çã«getã®ã¿ãªã®ã§ãå®åã¨ãã¦è¦ãããããã¨æãã次ã«ããç»é²ããURLã®HTMLãåå¾ãã¦ããã¼ã«ã«ã«ä¿åãã¦ããéå»ã®HTMLã¨é£ãéã£ã¦ãããæ´æ°ãç¥ããããæ©è½ãå®è£ ããã
â»ã©ããã¨ã³ã³ã¼ãé¢ä¿ãè¦æãªã®ã§ãä¸ã®ã¹ã¯ãªããã¯shift-jisã§æ¸ãã¦ã¾ãã
use strict; use Encode; use LWP::Simple; my $content = get("http://d.hatena.ne.jp/heilig_zwei/"); #ãã¼ã«ã«ã«ä¿åããéå»ã®HTMLæ å ±ãéã open(IN,"<log.txt") || die "Open Error : log.txt\n"; my $old_page; foreach (<IN>){ $old_page .= "$_"; } close(IN); #æ°ããåå¾ãããã®ã¨ç §å if ($old_page eq $content){ print "\æ´æ°ã¯ããã¾ããã\n"; }else{ open(IN,">log.txt") || die "Open Error : log.txt\n"; print IN $content; close(IN); print "\æ´æ°ãããã¾ããã\n"; } sleep(2);
ã以ä¸ãã¹ã¯ãªãããå®è¡ããã¨ããæ´æ°ãããã¾ãããããæ´æ°ã¯ããã¾ããããã®ããããã表示ããããã¡ãªã¿ã«Google Adsenseã¿ãããªåçã³ã³ãã³ããå ¥ããã¨ãã¢ã¯ã»ã¹ãããã³ã«æ´æ°ããã£ãã¨å¤æããããããããåç¬ã§ã¯å®ç¨æ§ã¯çç¡ããã ãå ã»ã©ãè¿°ã¹ãããã«ãLWP::Simpleã¯æ£è¦è¡¨ç¾ã¨çµã¿åããããã¨ã§é常ã«æ¥½ãããªãã®ã§ãè²ã 試ãã¦ã»ãããããããã°ajaxのクロスドメイン制約を解消する時ã«ãLWP::Simpleã¯ä½¿ã£ãæ°ããããªã
ã次åã¯ãURLãèªååéãããããã°ã¤ã³ãã©ã¼ã ãéä¿¡ãã¦ããã°ã®èªåæ¸ãè¾¼ã¿ããããããå°ãbotã£ã½ããã®ã«ãªãäºå®ã
â次è¨äºï¼5/3æ´æ°ï¼
Bot作成講座2 - Perlでさくっとスパムブログを作ってみる - 後ろを見ろ、後ろを!
åèå³æ¸
Spidering hacksâã¦ã§ãæ å ±ã©ã¯ã©ã¯åå¾ãã¯ããã¯101é¸
- ä½è : Kevin Hemenway,Tara Calishain,æä¸é ç«
- åºç社/ã¡ã¼ã«ã¼: ãªã©ã¤ãªã¼ã»ã¸ã£ãã³
- çºå£²æ¥: 2004/05
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 52人 ã¯ãªãã¯: 904å
- ãã®ååãå«ãããã° (104件) ãè¦ã