Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

16 Experts available now in Live!

Get 1:1 Help Now