Skip to content

Instantly share code, notes, and snippets.

@anaetrezve
Created March 7, 2019 07:03
Show Gist options
  • Save anaetrezve/d02d658377461c2a784b22355328f249 to your computer and use it in GitHub Desktop.
Save anaetrezve/d02d658377461c2a784b22355328f249 to your computer and use it in GitHub Desktop.
Scrap image, href, text from a page with javascript console
var variable = [];
document.querySelectorAll('selector').forEach(item => {
variable.push({
title: item.querySelector('a').textContent,
content: item.querySelector('h1').textContent,
permalink: item.querySelector(' a').getAttribute('href'),
image: item.querySelector(' selector').getAttribute('src'),
cat: (function() {
if (item.classList.contains('some class')) {
return 'some class';
} else if (item.classList.contains('some class')) {
return 'some class';
} else {
return 'something';
}
}())
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment