i'm scraping sales first so i can see them at a glance to make my life easier. url:
http://www.audible.com/sp/3for2/basically it shows a list of books (image, title, author) but doesnt tell me the ratings / narrator until i hover over it. so i'm scraping that info and storing in local storage as json, as well as adding the narrator / ratings in color
Code
// ==UserScript==
// @name Audile Sales Scrape
// @namespace http://your.homepage/
// @version 0.1
// @description Lists all the books on an audible sale
// @author carteblanche
// @match http://www.audible.com/sp*
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
$(document).ready(function() {
var books = [];
// metadata container; i think this is everything i want
$(".adbl-sp-prod-meta-data-content").each(function(){
// console.log("found metadata container");
var title = $(this).children(".adbl-sp-prod-title").eq(0).html();
var author = $(this).children(".adbl-sp-prod-author").eq(0).html();
// there are three ratings, but i only want the first one
var ratings = $(this).find(".adbl-rating-num").eq(0).html();
// there are two strong; first is author, second is narrator. i only want the second
var narrators = $(this).find("strong").last().eq(0).html();
var book = {
title: title,
author: author,
ratings: ratings,
narrators: narrators
};
books.push(book);
// change author element to include narrator / ratings:
$(this).children(".adbl-sp-prod-author").eq(0).html(
'A: ' + author + '<br/>' +
'<span style="color:blue">N: ' + narrators + '</span><br/>' +
'<span style="color:green">#R: ' + ratings + '</span>'
);
});
localStorage['audibleSales'] = JSON.stringify(books);
console.log(JSON.stringify(books));
});
then a simple shell script to take the data from the local storage of the browser into a .json file
Code
sqlite3 "/home/jiggles/.config/chromium/Default/Local Storage/http_www.audible.com_0.localstorage" 'select cast(value as text) from itemtable' > /jiggles/temp/audible/books.json
thinking about it now, though, i dont really need sales info separate on my hard drive. maybe i'll build a page that shows me a friendly list instead of audible's bloated page with icons and sorted the way i want.
Before:

After: (narrators in blue, # ratings in green)
This post was edited by carteblanche on Jan 16 2015 10:27pm