Skip to content

Instantly share code, notes, and snippets.

@vlandham
Created November 1, 2012 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vlandham/3995151 to your computer and use it in GitHub Desktop.
Save vlandham/3995151 to your computer and use it in GitHub Desktop.
javascript scraping tips
// 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