日期:2014-05-18 浏览次数:21127 次
/// <summary>
/// 取得网页源码
/// </summary>
/// <param name="url">网页地址,eg: "http://www.yongfa365.com/" </param>
/// <param name="charset">网页编码,eg: Encoding.UTF8</param>
/// <returns>返回网页源文件</returns>
public static string GetHtmlSource(string url, Encoding charset)
{
//处理内容
string html = "";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream, charset);
html = reader.ReadToEnd();
stream.Close();
}
catch (Exception e)
{
}
return html;
}
------解决方案--------------------
貌似也只能这样把。
我现在采集还没用正则,不知道哪个效率高
------解决方案--------------------
有范围就正则取内容,没范围取全部!
------解决方案--------------------
http://jsq2f.p2sp.baidu.com/queryfid?type=str&url=qvod%3a%2f%2f104285780%7cA7E63C9014A6B181F3A775086A470FCBD198DD93%7c%e7%81%ab%e5%bd%b1%e5%bf%8d%e8%80%85472.rmvb%7c
我的这个地址 ,为什么 获取不了 网页源码啊
总是报:服务器提交了协议冲突. Section=ResponseStatusLine
------解决方案--------------------
顶下。实在是 不知道为什么了
------解决方案--------------------