Baidu crawlers of many ASP versions on the Internet are pasted with the Baidu indexing data acquisition method of Asp.net 2.0 and C. I hope you can correct it.
1 using system;
2 using system. Collections. Generic;
3 using system. text;
4 using system. net;
5 using system. Text. regularexpressions;
6 namespace Tool
7 {
8 public class seocount
9 {
10/*** // <summary> return to Baidu: number of entries included in a period
11 /// meaning of the strtimespan Parameter
12 // "1" select the number of entries to be queried in the last few days
13 // "1" query yesterday's records
14 // "7" query the records collected in the last week
15 // "30" query the records recorded in the last month
16 // "360" query the indexing status in the last year
17 // "0" query the total (ALL dates) records
18 /// </Summary>
19 /// <Param name = "strhostname"> </param>
20 /// <returns> </returns>
21 Public String baiducount (string strtimespan, string strhostname)
22 {
23 string uri = "http://www.baidu.com/s? Lm = "+ strtimespan +" & WD = site: "+ strhostname;
24 string html = new WebClient (). downloadstring (URI );
25 string pattern = @ "Baidu, find the relevant webpage [\ s] *? (? = Article, in use )";
26 // string number = new RegEx (@ "find related webpage ([\ D,] +)"). Match. Groups [1]. value;
27 string number1 = RegEx. Match (HTML, pattern, regexoptions. ignorecase). value;
28 string lastnumber = number1.replace ("Baidu, find the relevant webpage ","");
29 // if there are many articles to remove the approximate value, return a pure numeric string
30 if (lastnumber. Contains ("approx "))
31 {
32 lastnumber. Replace ("approx ","");
33}
34 // if neither of them returns 0
35 if (lastnumber = "")
36 {
37 lastnumber = "0 ";
38}
39 return lastnumber;
40
41}
42}
43}