Click here to Skip to main content
15,867,780 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
class="table table-striped table-bordered table-hover" dir="RTL" width="100%">

Hi Experts,

I need to extract a data table from a website, but I received an error.

"does not support this property or method."

What I have tried:

VB
Set hr = hDoc.body.getElementsByTagName("table table-striped table-bordered table-hover")
hr.lenght is zero why???
set hrr1 = hr.getElementsByTagName("th")  'error this line
Posted
Updated 14-Feb-22 9:30am
v2
Comments
Richard MacCutchan 14-Feb-22 7:50am    
It would help you to get more answer to your questions if you used the correct language tags, rather than VBA for everything.

1 solution

JavaScript
1. Set hr = hDoc.body.getElementsByTagName("table table-striped table-bordered table-hover")
2. set hrr1 = hr.getElementsByTagName("th") 'error this line

Line 1 returns a HTMLCollection - Web APIs | MDN[^] of all elements that have the named tagid. But the HTMLCollection does not have a getElementsByTagName method.

Also, if the length field of item hr is zero then it means that no items were found with that tag. And in your code you are trying to refer to it by the name of its class, rather than the HTML tag name. See Document.getElementsByClassName() - Web APIs | MDN[^].
 
Share this answer
 
v3
Comments
Maciej Los 14-Feb-22 11:33am    
5ed!
Richard MacCutchan 14-Feb-22 11:43am    
Thanks Maciej. It's amazing what you can learn by RTFM. :)
Maciej Los 14-Feb-22 13:10pm    
Oh, yeah!
[no name] 15-Feb-22 2:23am    
Dear Experts tagged the vba because am working on it ( ACCESS - VBE ) by open the url in webbrowser there is no problem to extract data table but when use 《htmlfile》 object some web site give the table length to zero , but in webbrowser simply to use getelementsbyTagName("Table")(2) ..... now how can extract the All table name or class ???
Richard MacCutchan 15-Feb-22 3:49am    
I explained how to get the information in my answer above. You need to use the correct API calls, and pass the correct parameter values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900