473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Incomplete WebResponse?

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
Nov 20 '05 #1
10 2981
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

Nov 20 '05 #2
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>...
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

Nov 20 '05 #3
Hi Chris,

What is not a complete page than?

Cor
Nov 20 '05 #4
I'll get a random number of bytes (never consistent) and I'll never
get the closing body and html tags. It's as though I only get half the
html. I have tinkered with the timeout but it never throws an
exception - of any kind.

"Cor Ligthert" <no**********@planet.nl> wrote in message news:<Oj*************@TK2MSFTNGP11.phx.gbl>...
Hi Chris,

What is not a complete page than?

Cor

Nov 20 '05 #5
Hi Chris,

And it is sure a HTML page not something as a bytearrea?

Maybe you can download the file doing a webclient download to see the file.
\\\
Dim wbc As New System.Net.WebClient
wbc.DownloadFile(Uri, Filename)
///
Than you can see the file normaly

Otherwise I think that we are just guessing

I hope this helps?

Cor
Nov 20 '05 #6
Hello Cor,

Well, that worked. But I'd like to eliminate the need to use the
local filesystem. Any other ways to handle this?

thx - Chris

"Cor Ligthert" <no**********@planet.nl> wrote in message news:<OA**************@TK2MSFTNGP11.phx.gbl>...
Hi Chris,

And it is sure a HTML page not something as a bytearrea?

Maybe you can download the file doing a webclient download to see the file.
\\\
Dim wbc As New System.Net.WebClient
wbc.DownloadFile(Uri, Filename)
///
Than you can see the file normaly

Otherwise I think that we are just guessing

I hope this helps?

Cor

Nov 20 '05 #7
HI Chris,

Is the file a real HTML page with a start HTML tag and an end HTML tag?

Cor
Hello Cor,

Well, that worked. But I'd like to eliminate the need to use the
local filesystem. Any other ways to handle this?

thx - Chris

Nov 20 '05 #8
Yes, I get the entire page. When I use any of the other methods of
pulling it down that return a stream, I don't get the entire page.
I've tried:

WebClient.OpenRead
WebClient.DownloadData
WebRequest.GetResponse

Only WebClient.DownloadFile works consistently. The other three
methods work on other sites, but for whatever reason, amazon.com gives
me a problem. The symptoms:

1. The result comes back quickly.
2. No exceptions are thrown.
3. The page is never complete.
4. The cutoff point is never in the same spot in the page.
5. The size of the stream is never the same.
6. When "sniffing" the underlying protocol using Ethereal, it cuts off
just as it does in the software.
7. The same problem occurs on other computers that I have.

Arrrrrrgh! Why just amazon.com?

thx - Chris

"Cor Ligthert" <no**********@planet.nl> wrote in message news:<uS*************@TK2MSFTNGP11.phx.gbl>...
HI Chris,

Is the file a real HTML page with a start HTML tag and an end HTML tag?

Cor
Hello Cor,

Well, that worked. But I'd like to eliminate the need to use the
local filesystem. Any other ways to handle this?

thx - Chris

Nov 20 '05 #9
Hi Chris,

This did work for me (see that I have used the RichTextbox, the textbox does
not)

Will you tell if you with this keeps the problems?

Cor
\\\
Dim myReg As Net.HttpWebRequest = _
DirectCast(Net.WebRequest.Create("http://www.amazon.com"), _
Net.HttpWebRequest)
Dim myResp As Net.HttpWebResponse = _
DirectCast(myReg.GetResponse(), Net.HttpWebResponse)
Dim myStream As IO.Stream = myResp.GetResponseStream()
Dim myreader As New IO.StreamReader(myStream)
Dim mystring As String = myreader.ReadToEnd()
Me.RichTextBox1.Text = mystring
myResp.Close()
///
Nov 20 '05 #10
Cor - you are a freaking genious! GENIOUS! I would like to kindly
repay you for your help. Shoot me an email plz!

I swapped out my textbox for the richtext box and whammo it worked.

thx - Chris

"Cor Ligthert" <no**********@planet.nl> wrote in message news:<ub**************@TK2MSFTNGP12.phx.gbl>...
Hi Chris,

This did work for me (see that I have used the RichTextbox, the textbox does
not)

Will you tell if you with this keeps the problems?

Cor
\\\
Dim myReg As Net.HttpWebRequest = _
DirectCast(Net.WebRequest.Create("http://www.amazon.com"), _
Net.HttpWebRequest)
Dim myResp As Net.HttpWebResponse = _
DirectCast(myReg.GetResponse(), Net.HttpWebResponse)
Dim myStream As IO.Stream = myResp.GetResponseStream()
Dim myreader As New IO.StreamReader(myStream)
Dim mystring As String = myreader.ReadToEnd()
Me.RichTextBox1.Text = mystring
myResp.Close()
///

Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jonathan | last post by:
Calling the System.Net.WebResponse.GetResponse method (see code below) results in the following error: System.Net.WebException: The underlying connection was closed: An unexpected error occurred...
0
by: Johann Blake | last post by:
In my need to decode a JPEG 2000 file, I discovered like many that there was no functionality for this in the .NET Framework. Instead of forking out a pile of cash to do this, I came up with the...
2
by: gizmo | last post by:
Hi, I'm using the following code to request the html source from the quoted site. ...... string url = "http://www1.soccerstand.com/"; WebRequest webRequest = WebRequest.Create(url);...
2
by: trialproduct2004 | last post by:
Hi all. i am having problem at a time of validatiang url. I am using webrequest and webresponse class to get content of particular url. My problem is after using webrequest and webresponse class...
2
by: Jeff G. | last post by:
Hello everyone, I have read through the newsgroups (thank God for 'em!) extensively looking for an example of how to pass a file (PDF) from a webresponse stream down to a web client. Here's the...
1
by: Mr Flibble | last post by:
OK I logon to a web site and I manage to get an SMSESSION cookie that I then store in a variable called _session (a class scoping variable). I do this by calling a logon URL and setting a cookie...
0
by: archana | last post by:
Hi all, I am facing very strange problem while using webrequest. What i am doing is i have one url which i want to validate. so i am using webrequest and webresponse. My code is as below:-...
3
by: KyleUbenk | last post by:
Well I have a multi-threaded program which downloads URL sources from the web. Im doing this multiple times at once. The only problem I see is that sometimes it takes a while to download the...
1
by: vito16 | last post by:
Hi, I have some C# code for a console application that was correctly grabbing pages until recently were the data is now incomplete. I am needing to grab all information including sponsored links...
4
by: CindyH | last post by:
Hi - hope someone can help with this - this code was working for a while in the 'real' code and then suddenly stopped - not sure what happen. I made two simple forms on localhost to try to test...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.