Skip to content

Instantly share code, notes, and snippets.

@JT5D
Created September 15, 2012 17:50
Show Gist options
  • Save JT5D/3729038 to your computer and use it in GitHub Desktop.
Save JT5D/3729038 to your computer and use it in GitHub Desktop.
WestLaw Scraper
// ==UserScript==
// @name WestLaw Scraper
// @namespace http://userscripts.org/users/
// @include http://weblinks.westlaw.com/result/*
// @require http://code.jquery.com/jquery-1.8.1.min.js
// @require https://raw.github.com/tmcw/happen/master/src/happen.js
// @version 1
// @grant GM_log
// ==/UserScript==
var html_content = '';
var laws = localStorage.getItem('laws');
if (laws) {
laws = JSON.parse(laws);
console.log(laws.length, ' scraped');
} else {
laws = [];
}
$('.DocumentTextGroupBox *').contents().filter(function() {
return this.nodeType === 3;
}).each(function(i, t) {
html_content += t.nodeValue + '\n';
});
var doc = {
content: html_content,
title: $('#headerTitleTruncate1').text()
};
laws.push(doc);
localStorage.setItem('laws', JSON.stringify(laws));
function download_results() {
var laws = localStorage.getItem('laws');
document.location = 'data:Application/octet-stream,' +
encodeURIComponent(laws);
}
var $next = $('a[title="Next Document"]');
if ($next) {
console.log('next available');
happen.click($next[0]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment