Utilizing getElementsByClassName for web scraping: encountering inaccurate outcomes

I am attempting to extract the inner text from all classes with the className = "disabled" within the provided snippet of HTML Code: HTML code

In my effort to achieve this task using MS Access (VBA), the code I have implemented is as follows:

Set IE = CreateObject("InternetExplorer.Application")

claimLink = "https://www.XXXXX.com/"


IE.navigate claimLink
    Do
       DoEvents
    Loop Until IE.ReadyState = 4

Set menuEnabled = IE.Document.getElementsByClassName("disabled")(0)


For Each Item In menuEnabled
    MsgBox (Item.innerText & " --> " & Item.className)
Next

IE.Quit

Set menuEnabled = Nothing
Set searchres = Nothing
Set IE = Nothing

However, the outcomes I receive encompass all items in the list, with MS Access indicating that the className for all these items (Bibliographic data, Description, Claims, etc.) is "disabled".

If possible, could someone kindly point out to me what might be incorrect in my Code? My objective is solely to retrieve "Description," "Claims," and "Cited Documents."

Only these Grey items are the ones I wish to capture

Thank you! Kornelius

Answer №1

After some observation, it seems like there is a brief delay for the elements to be updated. I have implemented a css selector combination to pinpoint the specific elements.

.epoContentNav [class=disabled]

The "." signifies a class selector, targeting elements with a matching class name after the dot, such as epoContentNav. The " " serves as a descendant combinator, indicating that the elements on the right are children of those on the left. The [] denotes an attribute selector, used here in conjunction with attribute=value to specify that the class name must be disabled. In essence, this selector instructs the code to locate elements with the class disabled within a parent element with the class epoContentNav, effectively identifying all disabled navigation bar items.

You can find more information about these selectors here.

Option Explicit    
Public Sub GetInfo()
    Dim IE As New InternetExplorer, i As Long, nodeList

    With IE
        .Visible = True
        .navigate "https://worldwide.espacenet.com/publicationDetails/claims?DB=&ND=&locale=en_EP&FT=D&CC=DE&NR=1952914A&KC=A&tree=false#"

        While .Busy Or .readyState < 4: DoEvents: Wend

        Application.Wait Now + TimeSerial(0, 0, 2)

        Set nodeList = .document.querySelectorAll(".epoContentNav [class=disabled]")
        For i = 0 To nodeList.Length - 1
            Debug.Print nodeList.item(i).innerText, nodeList.item(i).getAttribute("class")
        Next
        Stop
        'Quit '<== Remember to quit application
    End With
End Sub

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing browser local storage in web development

Currently, I am in the midst of working on an e-commerce platform, a project that holds significant importance for me as it marks my debut into major projects. For the first time, I am delving into the realm of local storage to manage basket data such as q ...

Get the content from a webpage, find and calculate the total count of div elements with a specific class, and display that number

Greetings everyone, I've run into a bit of a roadblock. My goal is to create a basic script that can count the number of servers currently running on this map by scraping the webpage, calculating the divs with the class ".row ark_srv1", and then displ ...

The art of controlling iframe elements with jquery

I've been researching various topics related to this issue, but I'm still unable to achieve the desired outcome. Currently, I am embedding an iframe within an HTML document like so: <iframe class="full-screen-preview__frame" id="nitseditpre ...

The background colors are not extending to the full width of the screen

I am facing an issue in my CSS code while trying to create a footer. The background color is not filling the width of the screen, and I had encountered the same problem earlier. Here is how it looks: () HTML Code: *{ margin: 0; padding: 0%; b ...

Discover the elusive tag that holds the specified text

My code snippet in HTML looks like this: <body> <div class="afds"> <span class="dfsdf">mytext</span> </div> <div class="sdf dzf"> <h1>some random text</h1> ...

Error: Trying to access the parent node of an undefined property

After incorporating this script into my webpage for the newsletter sign-up process, I aimed to reveal customized content post user subscription. <script> function insertAfter(referenceNode, newNode) { referenceNode.parentNode.insertBefore(newNode ...

Creating visually appealing Jquery-ui tab designs

Trying to customize the jquery tabs, I experimented with styling them to my liking. One thing I did was attempt to reduce the size of the tabs by adding a height:45px; to the UI stylesheet shown below. .ui-tabs-vertical .ui-tabs-nav li { clear: left; ...

A guide on implementing a .click function with jQuery

I have a code snippet that is supposed to add 100 to a number in a MySQL table when a button is clicked. However, the code does not work as expected. When I click the button, nothing happens, but if I refresh the page, it adds 100 to the number. Can some ...

Updating values in MySQL using PHP requires two consecutive reloads

Hey there! I recently created a message deletion button, but for some reason, it takes two reloads to see the changes pop up. The rest of my code is working fine, so I won't be sharing that part here... <?php while($r = $replies->fet ...

Troubleshooting CSS Hover Not Displaying Properly in Angular 14

In the footer class of my HTML, there is a code snippet with chevrons: <div class="link-list"> <div *ngFor="let link of insideLinksLeft | originalOrderKeyValue" class="link"> <a [href]="link.val ...

When you click on the button, the section will not be displayed

I'm facing an issue with my code. I have a set of five buttons and corresponding sections. When a button is clicked, the active and active-btn classes are supposed to be added to that button as well as the corresponding section element with the same i ...

Collapsing one tab when another is selected in the accordion interface

I have successfully implemented an accordion feature, but I am facing an issue where the tabs do not close when another one is clicked. Currently, they only open but fail to close the previously opened tab... Below is the code snippet for reference: < ...

What is the reason for having a space between the <body> and the <html> tags?

Can you explain why there is a gap between the top of the green box and the browser window in Chrome and Firefox? I've tried various CSS configurations to eliminate the apparent space between the html and body elements, but it seems that some padding ...

Why isn't the selected option appearing first?

I have written a PHP code to display the specified div <div id="main_catsel"> <select id="maincat" > <option value="1">none</option> <option value="2">Computer</option> <option value="4">Refrigerator& ...

Engaging with JSON data inputs

Need help! I'm attempting to fetch JSON data using AJAX and load it into a select control. However, the process seems to get stuck at "Downloading the recipes....". Any insights on what might be causing this issue? (Tried a few fixes but nothing has w ...

Is there a way for me to duplicate a complex element multiple times within the same page?

As an illustration, let's say I have a social tab located in my header that I would like to duplicate in the footer. This tab is comprised of various buttons with SVG images on top, event listeners linked to button IDs, and CSS styling. One option is ...

What is the best method for importing specific variables from external Python files into your script?

Hey there, I'm currently working on implementing a similar document recommendation and search function through scraping news articles. Here's a Python file that fetches news articles and saves the data in an array. from daumnews import get_news_d ...

Accordion section appears on the webpage as it is loaded

I am currently working on implementing an accordion feature for my webpage. Everything is functioning correctly when I click the button, but there is one issue - the div opens automatically when the page loads. My goal is to have the div closed initially a ...

What is the most effective way to implement a CSS stylesheet on a particular individual element?

Just starting out in web development and I recently experimented with a CSS stylesheet on a basic HTML element. It worked great when I targeted the element by name like this: label { color: green; } However, I wondered if there was a way to apply sty ...

I am experiencing an issue with Bootstrap's Jumbotron where the bottom border is not visible even after setting it. I am quite curious as to why

I'm new to using bootstrap and I've encountered an issue with the Jumbotron class. Specifically, I have set a border for the Jumbotron and it appears on the top, left, and right sides, but for some reason, the bottom border is missing. After goi ...