Protected bool robot ()
{
Bool brtn = false;
String king_robots = "baiduspider + @ Baidu | googlebot @ Google | ia_archiver @ Alexa | iaarchiver @ Alexa | asw.ek @ asw.ek | yahooseeker @ yahoo | Sohu-search @ Sohu | @ Sohu | msnbot @ MSN ";
String ls_spr;
Ls_spr = request. servervariables ["http_user_agent"]. tostring ();
Char [] delimiterchars = {'| '};
Char [] x = {'@'};
String [] I1 = king_robots.split (delimiterchars );
For (INT I = 0; I <i1.length; I ++)
{
String [] Spider = I1 [I]. Split (X );
If (ls_spr.indexof (Spider [0]. tostring ()>-1)
{
Brtn = true;
Logrobots (Spider [1]. tostring ());
Break;
}
}
Return brtn;
}
Protected void logrobots (string SPR)
{
SPR = datetime. Now. tostring () + "|" + SPR;
Streamwriter SW;
Try
{
Sw = new streamwriter (server. mappath ("log.txt"), true, system. text. encoding. getencoding ("gb2312"); // If the parameter is set to false, rewrite it. If it is set to true, add SW to the end. writeline (SPR );
Sw. Close ();
}
Finally
{
}
}
Complete.
Add links to other websites. Only spider can see it.
Protected void addcontent ()
{
Streamreader SR;
Try
{
Sr = new streamreader (server. mappath ("logurl.txt"), system. Text. encoding. getencoding ("gb2312 "));
String input;
Char [] uper = {'| '};
Char [] xx = {'@'};
While (input = Sr. Readline ())! = NULL)
{
SB = Sb + "<p> ";
String [] url = input. Split (uper );
For (INT I = 0; I <URL. length; I ++)
{
String [] TT = URL [I]. Split (XX );
If (TT [0]. length> 0)
{
SB = Sb + "<a href =" + TT [0]. tostring () + "target = _ blank>" + TT [1]. tostring () + "</a> | ";
}
}
SB = Sb + "</P> ";
}
Sr. Close ();
}
Finally
{
}
}