Chrome DevTools tip #1

How to loop through JS elements by classname… useful for quickly scraping Google Scholar if you need somebody’s total number of citations:

var mytotal=0;// ClassName will likely be a string different to that shown:
let myquery = document.getElementsByClassName(“gsc_a_ac”)
for (var i=0, item; item = myquery[i]; i++) {
var mycount=parseInt(item.innerHTML);
console.log(mycount); // <== we can easily monitor the increment
console.log(mytotal); // <== we can easily copy/paste the answer

See it in use:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Oli Steadman

Bass/BV @StornowayBand. DataCat @AstraZeneca. Consulting via StoneStreetProductions.