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

170
Views
Create relationship between DOM Nodes

I am trying to scrape an e-commerce like site, where I need to establish a relationship between the Title of a listing and its description. The problem is that I do not know how to reliably do so, because some listings have a description - some don't. As a result I cannot reliably use a for loop in associating a title with a description. Could you please offer your suggestions ?

This is how I was thinking , but it doesnt work reliably:

const allTitles= document.querySelectorAll(".title");
const arrayOfTitlesAndDescription= allTitles.map((title,index) => { title :document.querySelectAll(".description")[index] } )

Thank you very much !

This image would help you understand better , if the question is unclear

EDIT:

const allCards= document.querySelectorAll(".card");
/// also tried with allCards directly
Array.from(allCards).forEach(card => card.querySelector(".description"));
/// This works, but I don't know how to tell which .card is which
document.querySelectorAll(".card").querySelector(".description")
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Search for some div tag that encloses both .title and .description and for each of such tag search weather its children have any description or not.

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!