Created
November 8, 2023 13:08
-
-
Save Ambrosiani/cc66ea82d39df42ac452c4fbc7e91058 to your computer and use it in GitHub Desktop.
Bookmarklet som hämtar resultat som csv från Svenska dagstidningar
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
// bookmarklet som hämtar resultat från aktuell sökning på tidningar.kb.se och lägger i urklipp. Lägg som bokmärke i webbläsaren! | |
javascript:(function() { | |
var csv = 'date,newspaper,page,url\n'; | |
var results = document.querySelectorAll('.result'); | |
results.forEach(function(result) { | |
var newspaper = result.querySelector(".title-text").textContent; | |
var date = result.querySelector(".date").textContent; | |
var url = "https://tidningar.kb.se" + result.querySelector(".image img").getAttribute("src").replace("_thumb.jpg", "/"); | |
var parts = url.split("/"); | |
var page = parts[parts.length - 2]; | |
csv += date + ',"' + newspaper + '",' + page + ',' + url + '\n'; | |
}); | |
navigator.clipboard.writeText(csv); | |
alert(csv); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment