Created
June 19, 2024 11:36
-
-
Save qubodup/c67755581d9bf5dbc665f8ad939bd2ec to your computer and use it in GitHub Desktop.
Scrape Google results page to csv (tsv, tab separated) userscript only link and title
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
// https://stackoverflow.com/a/26573281/188159 | |
javascript: (function (){ | |
function l(u, i) { | |
var d = document; | |
if (!d.getElementById(i)) { | |
var s = d.createElement('script'); | |
s.src = u; | |
s.id = i; | |
d.body.appendChild(s); | |
} | |
} l('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', 'jquery') | |
})(); | |
let all = ''; | |
let counter = 0; | |
$('h3').each(function(){ | |
counter += 1; | |
let title = $(this).text(); | |
let link = $(this).parent().attr('href'); | |
all += title + '\t' + link + '\n'; | |
}); | |
console.log(all); | |
console.log(counter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment