Skip to content

Instantly share code, notes, and snippets.

View ecairol's full-sized avatar

Esteban Cairol ecairol

  • Costa Rica
View GitHub Profile
@ecairol
ecairol / js-scrapper-google-results.js
Created November 8, 2023 21:02
Scrape Google paginated list
nodes = document.querySelectorAll('#center_col #search [role="heading"]');
Array.from(nodes).forEach((node) => {
const title = node.textContent.slice(0, 100);
const publisher = node.previousSibling.innerText;
const link = node.closest('a').getAttribute('href');
const date = new Date(node.parentNode.lastChild.innerText);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');