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

284
Views
Web scrapping in Chrome Console- iterate over rows in mat-tab element

DISCLAIMER: I do not know JS, it is an assignment for my work.

I have been asked to withdraw scrape some data from a Google Marketing page using Chrome Console.

The HTML code I need to scrape looks like this:

The code in the console

I made the following code where I created a dictionary and then used document.Selector()to take the data but I only take it from one row.

var IntegrationDetails = [{}]

IntegrationDetails[0]["Property Name"] = document.querySelector("JSPath").innerText

IntegrationDetails[0]["Advertiser"] = document.querySelector("JSPath").innerText

IntegrationDetails[0]["Tracking ID"] = document.querySelector("JSPath").innerText

IntegrationDetails[0]["Account"] = document.querySelector("JSPath").innerText

IntegrationDetails[0]["Organisation name"] = document.querySelector("JSPath").innerText

IntegrationDetails[0]["Integrations with reporting data"] = document.querySelector("JSPath").innerText

IntegrationDetails[0]["Integrations with Cost Data"] = document.querySelector("JSPath").innerText

IntegrationDetails[0]["Integrations with Remarketing Lists"] = document.querySelector("JSPath").innerText

copy(IntegrationDetails)

I do not know how to iterate over every row in the mat-tab element and append each row to the dictionary.

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

0

The solution that I found it worked is the one below. I also needed to increment the [i] based on the length of the table in order to not overwrite the data.

var IntegrationDetails = []

for(let i=0;i < document.querySelectorAll('mat-row').length; i++) {
    IntegrationDetails.push( {
        "Property Name":  document.querySelectorAll('mat-row')[i].querySelectorAll("mat-cell")[1].innerText,
        "Advertiser": document.querySelectorAll('mat-row')[i].querySelectorAll("mat-cell")[2].innerText,
        "Tracking ID" : document.querySelectorAll('mat-row')[i].querySelectorAll("mat-cell")[3].innerText,
        "Account" : document.querySelectorAll('mat-row')[i].querySelectorAll("mat-cell")[4].innerText,
        "Organisation name" : document.querySelectorAll('mat-row')[i].querySelectorAll("mat-cell")[5].innerText,
        "Int with report data" : document.querySelectorAll('mat-row')[i].querySelectorAll("mat-cell")[6].innerText,
        "Int with Cost Data" : document.querySelectorAll('mat-row')[i].querySelectorAll("mat-cell")[7].innerText,
        "Int with Remarketing Lists" : document.querySelectorAll('mat-row')[i].querySelectorAll("mat-cell")[8].innerText
    })
}

copy(IntegrationDetails)
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!