Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

272
Views
How to get around dynamic elements when web-scraping?

The code below works as I am able to click a button on the webpage using Python/Selenium/Firefox.

button on the webpage

driver.execute_script('''return document.querySelector('dba-app').shadowRoot.getElementById('configRenderer').shadowRoot.querySelector('ing-default-layout-14579').querySelector('dba-overview').shadowRoot.querySelector('ing-feat-agreement-overview').shadowRoot.querySelector('ing-ow-overflow-menu-14587').shadowRoot.querySelector('button')''').click()

However, some elements are dynamic and the numbers are changing anytime you rerun the script.

The changing elements:

  • 'ing-default-layout-14579'
  • 'ing-ow-overflow-menu-14587'

What must I do to get around the dynamic elements?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One option is to look for other attributes that stay the same across pageloads. For example, given your HTML, you could do:

document.querySelector('#configRenderer') // returns the config renderer element
document.querySelector('[data-tag-name="ing-default-layout"]') // returns the ing-default-layout element
document.querySelector('[data-tag-name="dba-overview]') // returns the dba-overview element

And so on. Or you could the same method to identify a parent or a child, and then navigate to the child or parent respectively.

If the HTML isn't stable enough even for that, another approach would be to search through all elements, and find the one(s) whose tagName starts with what you need.

for (const elm of document.querySelectorAll('*')) {
  if (elm.tagName.toLowerCase().startsWith('ing-ow-overflow-menu')) {
    // do stuff with elm, which is the overflow menu element
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!