Solved

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

Posted on 2006-06-28
3
182 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now