Research Results : Number 1

Thursday, 14 February 2008 11:21 by Frimbob

The Good News:

Well I think I have solved the problem of weather I can read  a web page into a word document directly, I found that the .Net Frame work has a WebRequest Class.

Quickly using the code found in the MSDN article and adding word-specific print code, I can now import a web-page directly.

Code:

 [code]

         ' Create a request for the URL.
        Dim request As WebRequest = WebRequest.Create("
http://www.aireview.com.au/index.php?act=view&catid=8&id=7944")
        ' If required by the server, set the credentials.
        'request.Credentials = CredentialCache.DefaultCredentials
        ' Get the response.
        Dim response As WebResponse = request.GetResponse()
        ' Display the status.
        'Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
        ' Get the stream containing content returned by the server.
        Dim dataStream As Stream = response.GetResponseStream()
        ' Open the stream using a StreamReader for easy access.
        Dim reader As New StreamReader(dataStream)
        ' Read the content.
        Dim responseFromServer As String = reader.ReadToEnd()
        ' Display the content.
        Dim r As Word.Range = Me.Application.ActiveDocument.Range
        r.Text = responseFromServer.Length
        'Console.WriteLine(responseFromServer)
        ' Clean up the streams and the response.
        reader.Close()
        response.Close()

 [/code]

The Problem:

Well to sum it up It doesn't work with the www.aireview.com.au web-site.

It appears that the stream that arrives only contains 69 characters, I am guessing that the stream is taken before the PHP script has finished queuing the database.

One problem fixed on Big Problem Found.

More Research is Needed.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Projects
Actions:   E-mail | Permalink | Comments (192) | Comment RSSRSS comment feed

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading