怎样解决用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代码
相关问答:
在发表评论时 过滤 如何:<br/> <hr/> 双引号 单引号 还有其他 等 有好的方法告诉一下 谢谢
.replace(/<\w+[^>]*>/g,"").replace(/'/g,"''")
将单引号换成2个 ......
怎么给html的file控件赋值?
这个貌似不能赋值吧。。。
只读的
只读。但可以仿照。不知道楼主要实现什么功能。
仿照就是一个文本框 + Button
只读的。不可以赋值。
可以使用flash
......
VBScript code:
while x<100
response.write "<div>xxxx</div>"
x= x+1
wend
循环输出 html代码
代码总是以下面的形式那样 在一行上的
HTML code:
<div>xxxx</div> ......
我通过 BACKGROUND: url(images/s.gif) no-repeat 0px 0px; 调整到图片的位子正好的时候。可是图片会根据浏览器窗口的大小不固定。
请看图
A:hover {
COLOR: #1e50c1; TEXT-DECORATION: underline; ......
分页点击下一页时, 页数会刷新而内容不会刷新,怎么解决
贴代码
为什么第一页有内容显示而以后的每一页都没有,并且也从数据库中读出这些数据了
1。这个问题和CSS没有关系
2。不知道你是在前台分页的还是 ......