不完整的WebResponse? [英] Incomplete WebResponse?

查看:93
本文介绍了不完整的WebResponse?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发出请求,将其填入stringbuffer,然后将其附加到

文本框中。它适用于许多网站(例如yahoo.com),但不适用于其他许多网站(例如amazon.com)。任何可以提供的见解将是

非常感谢。


相关代码:


Sub GetPage()

尝试


Dim loRequest As HttpWebRequest

Dim loResponse As HttpWebResponse

Dim loSR As StreamReader

Dim loSB作为新的StringBuilder


loRequest = CType(WebRequest.Create(" http://www.amazon.com"),

HttpWebRequest)

loResponse = CType(loRequest.GetResponse(),HttpWebResponse)

loSR =新StreamReader(loResponse.GetResponseStream,

Encoding.ASCII)

loSB.Append(loSR.ReadToEnd)

loSR.Close()


txtStatus.AppendText( loSB.ToString)


Catch ex As Exception

MessageBox.Show(ex.ToString)

结束尝试


结束子

I make a request, stuff it into a stringbuffer, then append it to a
textbox. It works on many sites (e.g. yahoo.com), but not on many
others (e.g. amazon.com). Any insight that could be provided would be
greatly appreciated.

Relevant code:

Sub GetPage()
Try

Dim loRequest As HttpWebRequest
Dim loResponse As HttpWebResponse
Dim loSR As StreamReader
Dim loSB As New StringBuilder

loRequest = CType(WebRequest.Create("http://www.amazon.com"),
HttpWebRequest)
loResponse = CType(loRequest.GetResponse(), HttpWebResponse)
loSR = New StreamReader(loResponse.GetResponseStream,
Encoding.ASCII)
loSB.Append(loSR.ReadToEnd)
loSR.Close()

txtStatus.AppendText(loSB.ToString)

Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try

End Sub

推荐答案

嗨克里斯,


可能很简单,

很多网站页面都是se perate文件。

一个框架容器文件和框架文件。


因此,当你试图像你一样得到它们时,你得到框架容器,试着

逐个找到单独的框架。


我希望这有帮助吗?


Cor

Hi Chris,

Probably an easy one,
A lot of site pages exist as seperate documents.
A frame containerdocument and framedocuments.

So when you try to get them as you do, you get the frame container, try to
find the seperate frames one by one.

I hope this helps?

Cor


当我说它不起作用时,我的意思是我收到来自

网络服务器的回复,但我没有得到完整页面。我错过了什么?

ch ********* ****@hotmail.com (Chris Coddington)在留言中写道:< 77 ************************** @ posting.google。 com> ...
When I say that it doesn''t work, I mean that I get a response from the
webserver but I don''t get the complete page. What am I missing?

ch*************@hotmail.com (Chris Coddington) wrote in message news:<77**************************@posting.google. com>...
我发出请求,将其填入stringbuffer,然后将其附加到
文本框中。它适用于许多网站(例如yahoo.com),但不适用于其他许多网站(例如amazon.com)。非常感谢任何可以提供的见解。

相关代码:

Sub GetPage()
尝试
Dim loRequest As HttpWebRequest
Dim loResponse As HttpWebResponse
Dim loSR As StreamReader
Dim loSB As New StringBuilder

loRequest = CType(WebRequest.Create(" http: //www.amazon.com"),
HttpWebRequest)
loResponse = CType(loRequest.GetResponse(),HttpWebResponse)
loSR =新的StreamReader(loResponse.GetResponseStream,
编码) .ASCII)
loSB.Append(loSR.ReadToEnd)
loSR.Close()

txtStatus.AppendText(loSB.ToString)

Catch ex作为例外
MessageBox.Show(ex.ToString)
结束尝试

End Sub
I make a request, stuff it into a stringbuffer, then append it to a
textbox. It works on many sites (e.g. yahoo.com), but not on many
others (e.g. amazon.com). Any insight that could be provided would be
greatly appreciated.

Relevant code:

Sub GetPage()
Try

Dim loRequest As HttpWebRequest
Dim loResponse As HttpWebResponse
Dim loSR As StreamReader
Dim loSB As New StringBuilder

loRequest = CType(WebRequest.Create("http://www.amazon.com"),
HttpWebRequest)
loResponse = CType(loRequest.GetResponse(), HttpWebResponse)
loSR = New StreamReader(loResponse.GetResponseStream,
Encoding.ASCII)
loSB.Append(loSR.ReadToEnd)
loSR.Close()

txtStatus.AppendText(loSB.ToString)

Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try

End Sub



你好克里斯,


什么不是一个完整的页面?


Cor
Hi Chris,

What is not a complete page than?

Cor


这篇关于不完整的WebResponse?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆