Access/VBA Library

scrapeTable Method

Scrape and return the content of one or more tables.

See also: https://www.w3schools.com/cssref/css_selectors.asp

Syntax

clsIE.scrapeTable( cssSelector )
Parameters
Name Type Description
clsIE   The name of an object of type clsIE
cssSelector String Required. Pattern to select the table(s) on the current webpage.
Return value

Collection : This collection contains for every row found a collection containing the content of every cell.

clsIEtag:clsIE

Remarks

  • Be aware of the fact that multiple tables may match the pattern specified by cssSelector and this method will return all rows of all these table.
Example
Dim IE As New clsIE
Dim rates As Collection
Dim index As Long
Dim row As Collection

IE.location = "https://www.x-rates.com/table/?from=EUR&amount=1"
'
' Select the table with class "ratesTable". The
' webpage containes 2 tables, so use :first-of-type to select
' only the first table!
Set rates = IE.scrapeTable("table.ratesTable:first-of-type")
For index = 1 To rates.count
    Set row = rates(index)
    Debug.Print row(1) & ";" & row(2) & ";" & row(3)
Next index
'Possible results:
'Euro;1.00 EUR;inv. 1.00 EUR
'US Dollar;1.130998;0.884175
'British Pound;0.883413;1.131974
'Indian Rupee;81.367698;0.012290
'Australian Dollar;1.556322;0.642540
'Canadian Dollar;1.496026;0.668437
'Singapore Dollar;1.557467;0.642068
'Swiss Franc;1.136571;0.879839
'Malaysian Ringgit;4.738270;0.211048
'Japanese Yen;128.283191;0.007795
'Chinese Yuan Renminbi;7.848841;0.127407