本帖最后由 千年 于 2012-12-12 20:43 编辑
查不到百度的收录,请问是哪的问题
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
namespace ConsoleApplication115
{
class Program
{
static void Main(string[] args)
{
int strTimespan = 0;
string strHostName = "www.baidu.com";
string uri = "http://www.baidu.com/s?lm=" + strTimespan + "&wd=site:" + strHostName;
string html = new WebClient().DownloadString(uri);
//System.Text.Encoding.GetEncoding("GB2312");
string patterna = @"找到相关结果数(?<number>.*)个";
string number1 = new Regex(patterna).Match(html).Groups["number"].Value;
string lastnumber = number1.Replace("找到相关结果数", "");
Console.WriteLine(lastnumber);
Console.ReadKey();
}
}
}
|