Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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