1

I've looked at about 30 different questions, and each one deals with "getelementbyID". My issue is the element I need to scrape doesn't have an id:

The element I want, and its HTML code

Full view of the HTML

I see it is inside of an "h6" class or tag, but

    msgbox IEObj.Document.getelementsbytagname("h6").Value
    msgbox IEObj.Document.getelementsbyclassname("h6").Value

just returns the "Object doesn't support this property or method". What am I doing wrong?? (The rest of the code just sets up a IE Object called IEObj, and navigates to this page, so it's unimportant).

2
  • what might be more useful is if we can see more of the html. Commented Jun 3, 2016 at 20:18
  • 1
    getElementsbyClassName and getElementsByTagName gives you an array back. Basically it gives you all items back, as Class and tagName are not unique unlike ID's. You need to specify which item you want. Like: IeObj.Document.getElementsByTagName("h6")(0).InnerText Commented Jun 3, 2016 at 20:28

2 Answers 2

1

you must find the h6 which the innertext is "Expected delivery". Then, get the innertext of h6.

dim webH6 as object, webTag as object, deliveryDate as variant
    for each webH6 in ie.document.getelementsbytagname("h6")
        if webH6.getelementsbytagname("a")(0).innertext = "Expected delivery" then
            deliveryDate = trim(replace(webH6.innertext, ":", ""))
            exit for
        end if
    next webH6
Sign up to request clarification or add additional context in comments.

3 Comments

Yes, this should work, but I get a "Object doesn't support this method" error on the second line. Seriously. That's why I came here in the first place, since every tutorial and help site I've seen gives the same advice and it gives the same error...
i correct line 2 from ie.getelementsbytagname("h6") to ie.document.getelementsbytagname("h6").
@C-Love511 If my answer can solve your problem, could you please accept my answer? I am new here, so I need reputation.
0

Okay, the answer above me is correct.

Actually, all of the tutorials are.

I kept getting "Permission denied" errors (70) when I'd loop through the elements. Turns out that the website detects scripts and stops them from running for security reasons. Otherwise, the code should work perfectly!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.