怎样解决用HttpWebRequest来获取超长网页的html代码
超长网页的地址:
http://club.autohome.com.cn/bbs/thread-c-813-4881481-1.html
哪位大侠可以提供一份代码给我,可以成功的获取上面地址的html代码,谢谢。
试过很多HttpWebRequest写的代码,但是没有一个管用,程序运行几分钟之后,最终报错:操作已经超时。
但是用IE浏览器却可以正常打开。
C# code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
Console.Write(getHtml("http://club.autohome.com.cn/bbs/thread-c-813-4881481-1.html"));
Console.Read();
}
protected static string getHtml(string url)
{
string html = "";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Accept = "*/*";
HttpWebResponse response = null;
Stream stream = null;
StreamReader reader = null;
try
{
response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
reader = new StreamReader(stream, Encoding.UTF8);
html = reader.ReadToEnd().Replace("\r\n", ""); //我知道这里会改变html代码
相关问答:
<span id="Label1">如果能看到这个标签 说明我们已经能从HTML 页面上获取了这个元素控件传递到Silverlight应用程序中 </span>
<br />
<input type="sub ......
.css1 .css2 #objid {OVERFLOW: scroll;...}
.css1 .css3 {...}
把具有共同样式的写到一起了 好维护
中间无逗号,属于样式嵌套
样式的共同的地方写在一起,可以省掉不必要的代码行~
这个就是代码 ......
用css缩写 使用缩写可以帮助减少你CSS文件的大小,更加容易阅读。css缩写的主要规则请参看《常用css缩写语法总结》,这里就不展开描述。
二.明确定义单位,除非值为0
忘记定义尺寸的单位是CSS新手普遍的错误。在HT ......
VBScript code:
while x<100
response.write "<div>xxxx</div>"
x= x+1
wend
循环输出 html代码
代码总是以下面的形式那样 在一行上的
HTML code:
<div>xxxx</div> ......
网页中嵌入一个ActiveX,怎样使用<param>指定字体?
如下:
<OBJECT ID="AX" CLASSID="CLSID:986E24CA-ABCD-1234-5678-04C63B177FB0">
<param name="Font" value=& ......