Created
September 2, 2024 11:04
-
-
Save usayamadx/73a96d257f2be1ce36c8b2ac008873e5 to your computer and use it in GitHub Desktop.
Chrome Dev Scraping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const imageElements = document.querySelectorAll('.search-card-e-slider__img'); | |
const companyElements = document.querySelectorAll('.search-card-e-company'); | |
let csvContent = "data:text/csv;charset=utf-8,Image URL,Company Name,Company URL\n"; | |
imageElements.forEach((img, index) => { | |
const imgUrl = img.src.startsWith('//') ? 'https:' + img.src : img.src; | |
const companyName = companyElements[index].textContent.trim(); | |
const companyUrl = companyElements[index].href.startsWith('//') ? 'https:' + companyElements[index].href : companyElements[index].href; | |
const row = `"${imgUrl}","${companyName}","${companyUrl}"`; | |
csvContent += row + "\n"; | |
}); | |
const encodedUri = encodeURI(csvContent); | |
const link = document.createElement("a"); | |
link.setAttribute("href", encodedUri); | |
link.setAttribute("download", "export.csv"); | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment