Created
March 7, 2019 07:03
-
-
Save anaetrezve/d02d658377461c2a784b22355328f249 to your computer and use it in GitHub Desktop.
Scrap image, href, text from a page with javascript console
This file contains 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
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