.net抓取html
来源:互联网 发布:云计算技术应用 编辑:程序博客网 时间:2024/06/06 04:23
// 获取网页的HTML内容,指定Encoding
static string GetHtml(string url, System.Text.Encoding encoding)
{
byte[] buf = new System.Net.WebClient().DownloadData(url);
if (encoding != null) return encoding.GetString(buf);
string html = System.Text.Encoding.UTF8.GetString(buf);
encoding = GetEncoding(html);
if (encoding == null || encoding == System.Text.Encoding.UTF8) return html;
return encoding.GetString(buf);
}
// 根据网页的HTML内容提取网页的Encoding
static System.Text.Encoding GetEncoding(string html)
{
string pattern = @"(?i)/bcharset=(?<charset>[-a-zA-Z_0-9]+)";
string charset = System.Text.RegularExpressions.Regex.Match(html, pattern).Groups["charset"].Value;
try { return System.Text.Encoding.GetEncoding(charset); }
catch (ArgumentException) { return null; }
}
- .net抓取html
- .net对html的抓取
- 抓取html网页
- 抓取指定的html
- 抓取指定的Html
- 正则抓取html表达式
- C#抓取html函数
- Python抓取html内容
- Python抓取HTML
- Python 抓取解析HTML
- 【数据抓取】HTML解析
- html页面数据抓取
- .net中 网页抓取数据(提取html中的数据,提取table中的数据)
- .NET 专题-网页抓取
- asp.net 网页抓取
- asp.net 抓取
- Asp.net数据抓取
- Asp.net数据抓取
- 使用水晶报表碰到“CrystalDecisions. CrystalReports.Engine.ReportDocument”的类型初始值设定项引发异常
- 什么样的人才可能当上领导?
- 写操作系统(一)执着 总述
- 无法共享打印机问题解决
- 使用grub启动虚拟软盘的方法
- .net抓取html
- 通通透透VFW视频采集
- ASP.NET应该遵守的9条代码编写规范
- 异常 Underlying input stream returned zero bytes 解决办法
- 如何在Windows下配置Android的Eclipse开发环境
- Struts配置文件详解
- 从别处找到的有关web打印的东西,自己用了一下,还真不错,解决我的大问题了
- Ajax入门
- Timeout 與 Idle