-
December 12th, 2006, 02:37 PM
#1
Downloading a table from a web page
I would like to download a table on a web page to a .csv or text file using VB.Net (not ASP.Net). Any ideas?
-
December 13th, 2006, 05:21 AM
#2
Re: Downloading a table from a web page
Where is this web page, on the internet, or is it just a web page on your system ¿
If you want to download code from a webpage on the internet, this will give you a good start :
Code:
Imports System.Net 'web request, web response
Imports System.IO 'streamreader
Imports System.Text 'encoding
Public Class Form1
Inherits System.Windows.Forms.Form
Friend Function GetHtmlCode(ByVal URL As String) As String
Dim WebRq As HttpWebRequest
WebRq = System.Net.HttpWebRequest.Create(URL)
Dim WebRsp As HttpWebResponse
WebRsp = WebRq.GetResponse()
Dim strmR As StreamReader = New StreamReader(WebRsp.GetResponseStream(), Encoding.ASCII)
Dim sLine As String = strmR.ReadToEnd
strmR.Close()
Return sLine
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str As String
str = GetHtmlCode("http://www.codeguru.com/forum/showthread.php?t=409011")
TextBox1.Text = TextBox1.Text & str
End Sub
This will read the entire contents of the file into a textbox
-
December 13th, 2006, 08:44 AM
#3
Re: Downloading a table from a web page
HannestheGreat:
Thanks for your quick reply. Yes, the table is from Internet. However, I don't want to get the result in html format; I have been able to do that and parse data to get what I want. But it is too cumbersome.
I am looking for a .csv format. For example, I would like to get the call and put options listed in the table at http://finance.yahoo.com/q/op?s=AAPL in.csv format so that retrieval of individual values from the table becomes a cinch.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|