Solved

How to open a web page and save it as txt?

Posted on 2006-06-28
3
186 Views
Last Modified: 2010-04-23
I assume this is a very easy question to answer and I saw a similiar one already but that didn't seem to do the trick for me.

Basically I want to open a site like below and then do a File-> Save Page(Save Page as in Mozilla) and set it as a text file.

 http://www.stephen.com/prices.txt

That is it, I've been able to start a web page using System.Diagnostics.Process.Start and I tried
using the WebBrowser object and navigating to it but I couldn't figure out what do after that.

Just want something simple.

0
Comment
Question by:brindelin
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 75 total points
ID: 17006893

Imports System.Net

        Dim Req As WebRequest
        Req = WebRequest.Create("http://www.google.com")

        Dim Resp As WebResponse
        Try
            Resp = Req.GetResponse()
            Dim Sr As Stream = Resp.GetResponseStream()
            Dim SRdr As New StreamReader(Sr)
            Dim Str As String = SRdr.ReadToEnd()
            SRdr.Close()
            Dim SWrt As New StreamWriter("c:\site.txt")
            SWrt.Write(Str)
            SWrt.Close()
         Catch ex As Exception
            MsgBox(ex.Message)
        End Try
0
 

Author Comment

by:brindelin
ID: 17009666
Thanks that was exactly what I was looking for.  Although I did have to change it to IO.Stream, IO.StreamReader, and IO.StreamWriter for anyone else using this as reference.

Thanks again.
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 17015925
Sorry forgot to say that you needed to Import System.IO as well
then you won't require the qualifier IO. just Stream would do
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question