Solved

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

Posted on 2006-06-28
3
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

687 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