Thursday, December 4, 2008

Extract data from HTML page

theURL = "www.rgagnon.com/masters/wsh-vbs.html"
with CreateObject("InternetExplorer.Application")
.Navigate("http://" & theURL)
Do until .ReadyState = 4
WScript.Sleep 50
Loop
With .document
set theTables = .all.tags("table")
nTables = theTables.length
for each table in theTables
s = s & table.rows(0).cells(0).innerText _
& vbNewLine & vbNewLine
next
wsh.echo "Number of tables:", nTables, vbNewline
wsh.echo "First table first cell:", s
' get the data with an ID
' msgbox ie.document.getelementbyid("d1").innerHtml
End With
End With
Output is :
>cscript ieextract.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. Tous droits réservés.
Number of tables: 1
First table first cell: VBScript

1 comment:

Website said...

hey nice information for us,thanks for sharing the nice information.I definitely bookmark this blog.

yell screen scraper

Custom Search