I'm using VB-2005
The following example works fine (I lent it from this forum from someone)
It uses a form with 2 buttons.
The first button starts a webbrowser with a webpage
The second button starts the ShowSaveAsDialog
This works fine, I can save my Webpage.
But:
Question1: How can I save the Webpage to c:\webpage.html from my program without manually use of ShowSaveAsDialog
Question2: How do i get the HTML-tables in a VB-array
Public
Class Form1 Friend WithEvents WB As New WebBrowser Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Controls.Add(WB)WB.Location =
New Point(20, 20)WB.Size =
New Size(250, 175)WB.ScrollBarsEnabled =
True End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickWB.Navigate(
"http://www.aex.nl/scripts/marktinfo/OptieFrame.asp taal=nl&symbool=AEX&a=1
") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickWB.ShowSaveAsDialog()
End SubEnd
Class
how to Download a webpage to harddisk?
Mazay
Hi,
This is not very good code (no error checking for the numerous things that could go wrong, but it should get the points across - which is that you can get the html content of the web page and write to a file all yourself :)
Dim oFS As System.IO.FileStream = System.IO.File.OpenWrite("C:\webpage.html") Dim oBytes() As Byte = System.Text.Encoding.ASCII.GetBytes(WB.DocumentText)oFS.Write(oBytes, 0, oBytes.Length)
oFS.Close()
Surovich
hello, Geoff Appleby
Thanks for your answer to my question.
But I suppose, you did not check if the information was the same as shown in a webbrowser. The requested webpage has frames.
Your example downloads only the first frame of the webpage. How can i make sure that all frames on the web page are downloaded, or otherwise select the frame i wish and then download the information in that frame
I also tried the following, which also downloaded only the first frame
Dim
webClient1 As New WebClient ' Download the Data into a Byte() array. Dim data() As Byte = webClient1.DownloadData("http://www.aex.nl/scripts/marktinfo/OptieFrame.asp taal=nl&symbool=AEX&a=1") ' Or download the data directly to a file.webClient1.DownloadFile(
"http://www.aex.nl/scripts/marktinfo/OptieFrame.asp taal=nl&symbool=AEX&a=1", "C:\webpage.html")Until now only with manual interaction after running the command:
WB.ShowSaveAsDialog()
all information in the webpage has been saved.
Is there a way use the ' WB.ShowSaveAsDialog( ) ' routine without manual interaction