C# 如何取得百度指数

XJQ_1 2009-08-09 10:28:58
如 我在百度 搜 CNDN

百度一下,找到相关网页约16,500,000篇,用时0.001秒


这个 16,500,000 如何取得,我用C# 写代码

...全文
869 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
day90 2009-10-25
  • 打赏
  • 举报
回复
没看明白lz要干啥

是问咋统计?

还是问咋取百度的结果?
yyhlove 2009-10-25
  • 打赏
  • 举报
回复
路过 学习下。帮定
xiaoxin4321 2009-10-25
  • 打赏
  • 举报
回复
学习了,~~
十八道胡同 2009-08-10
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 lxcnn 的回复:]
看不太明白需求,先取网页,再分析得到结果?

C# code//通过URL取网页源代码privatestring GetHtmlCode(string url, Encoding encoding)
{
System.Net.HttpWebRequest request= (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.UserAgent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
System.Net.WebResponse response= request.GetResponse();
System.IO.Stream resStream= response.GetResponseStream();
System.IO.StreamReader sr=new System.IO.StreamReader(resStream, encoding);string html= (sr.ReadToEnd());
resStream.Close();
sr.Close();return html;
}//调用,解析string html= GetHtmlCode("http://www.baidu.com/s?wd=CNDN", Encoding.GetEncoding("gb2312"));
Regex reg=new Regex(@"百度一下,找到相关网页约(?<count>\d{1,3}(?:,\d{3})*)篇");
Match m= reg.Match(html);if (m.Success)
{
richTextBox2.Text+= m.Groups["count"].Value+"\n";
}
[/Quote]

顶个
laoban108 2009-08-10
  • 打赏
  • 举报
回复
学习。
Dhoopu 2009-08-10
  • 打赏
  • 举报
回复
不懂,友情帮顶!!!
Dhoopu 2009-08-10
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 lxcnn 的回复:]
看不太明白需求,先取网页,再分析得到结果?

C# code//通过URL取网页源代码privatestring GetHtmlCode(string url, Encoding encoding)
{
System.Net.HttpWebRequest request= (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.UserAgent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
System.Net.WebResponse response= request.GetResponse();
System.IO.Stream resStream= response.GetResponseStream();
System.IO.StreamReader sr=new System.IO.StreamReader(resStream, encoding);string html= (sr.ReadToEnd());
resStream.Close();
sr.Close();return html;
}//调用,解析string html= GetHtmlCode("http://www.baidu.com/s?wd=CNDN", Encoding.GetEncoding("gb2312"));
Regex reg=new Regex(@"百度一下,找到相关网页约(?<count>\d{1,3}(?:,\d{3})*)篇");
Match m= reg.Match(html);if (m.Success)
{
richTextBox2.Text+= m.Groups["count"].Value+"\n";
}
[/Quote]

貌似这个方法不错嘛,支持下。这样直接把百度的信息抓过来了。准确而方便。
BitCoffee 2009-08-10
  • 打赏
  • 举报
回复
先获取网页源代码,再用正则匹配.
[Quote=引用 5 楼 lxcnn 的回复:]
看不太明白需求,先取网页,再分析得到结果?

C# code//通过URL取网页源代码privatestring GetHtmlCode(string url, Encoding encoding)
{
System.Net.HttpWebRequest request= (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.UserAgent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
System.Net.WebResponse response= request.GetResponse();
System.IO.Stream resStream= response.GetResponseStream();
System.IO.StreamReader sr=new System.IO.StreamReader(resStream, encoding);string html= (sr.ReadToEnd());
resStream.Close();
sr.Close();return html;
}//调用,解析string html= GetHtmlCode("http://www.baidu.com/s?wd=CNDN", Encoding.GetEncoding("gb2312"));
Regex reg=new Regex(@"百度一下,找到相关网页约(?<count>\d{1,3}(?:,\d{3})*)篇");
Match m= reg.Match(html);if (m.Success)
{
richTextBox2.Text+= m.Groups["count"].Value+"\n";
}
[/Quote]
-过客- 2009-08-09
  • 打赏
  • 举报
回复
看不太明白需求,先取网页,再分析得到结果?

//通过URL取网页源代码
private string GetHtmlCode(string url, Encoding encoding)
{
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
System.Net.WebResponse response = request.GetResponse();
System.IO.Stream resStream = response.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(resStream, encoding);
string html = (sr.ReadToEnd());
resStream.Close();
sr.Close();
return html;
}
//调用,解析
string html = GetHtmlCode("http://www.baidu.com/s?wd=CNDN", Encoding.GetEncoding("gb2312"));
Regex reg = new Regex(@"百度一下,找到相关网页约(?<count>\d{1,3}(?:,\d{3})*)篇");
Match m = reg.Match(html);
if (m.Success)
{
richTextBox2.Text += m.Groups["count"].Value + "\n";
}
wuyq11 2009-08-09
  • 打赏
  • 举报
回复
这是搜索引擎的抓取功能,爬虫程序,抓取页面可用
webclient,httpwebrequest等
或通过webbrower通过post提交获取页面内容
pengalwin 2009-08-09
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sql77 的回复:]
C# code这个应该与数据库表进行联系,然后查询匹配的记录行数,时间就计算一下就好了,数据库中也可以查询
STRING SQL="SELECT COUNT(*) FROM TB WHERE COL LIKE '%"+TEXTBOX.TEXT+"%'";
[/Quote]
对的
SQL77 2009-08-09
  • 打赏
  • 举报
回复
这个应该与数据库表进行联系,然后查询匹配的记录行数,时间就计算一下就好了,数据库中也可以查询
STRING SQL="SELECT COUNT(*) FROM TB WHERE COL LIKE '%"+TEXTBOX.TEXT+"%'";
sjdev 2009-08-09
  • 打赏
  • 举报
回复
不知道。帮顶。

110,546

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧