Created
November 1, 2012 17:21
javascript scraping tips
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
// local storage from | |
// http://macwright.org/2012/09/06/scrapers.html | |
var laws = localStorage.getItem('laws'); | |
if (laws) { laws = JSON.parse(laws); | |
} else { laws = []; } | |
laws.push({ title: 'New!' }); | |
localStorage.setItem('laws', JSON.stringify(laws)); | |
var laws = localStorage.getItem('laws'); | |
document.location = 'data:Application/octet-stream,' + encodeURIComponent(laws); | |
// could also use straight variable | |
document.location = 'data:Application/octet-stream,' + encodeURIComponent(JSON.stringify(aVar)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment