CORRECTION – Using BASH to sort a book collection. ISBN Data Mining – Part 1
This may be cheating but I consider it a break from the download cleanup script.
Amazingly I got a comment out of the blue from an article I wrote in 2007 about ISBN Data Mining. The comment, stated the fact that the script didn’t work. I did a little investigating and was able to find out why. I figured it was just old and didn’t work but that was not the case. Apparently when I formatted my posts for code, a while back it appears that some of the formatting got a bit fubar.
Luckily for me and Gabe I was able to find an old copy:
Here is his script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/bin/bash ISBN="$1" function fetchInfo () { ### Using barnesandnoble.com to fetch info... lynx -source "http://search.barnesandnoble.com/booksearch/isbninquiry.asp?ISBN=${ISBN}" |\ tr -d '[:cntrl:]' | sed 's/></>\n</g' | while read -a lineArray; do ### Parsing book title. if [ "${lineArray[0]}" == "<h1" ]; then echo "4|Title: ${lineArray[*]}" | sed 's/<[^>]*>//g;s/ ([^)]*)//g' ### Parsing book author. elif [ "$(echo ${lineArray[*]} | grep "id=\"contributor\"")" ]; then echo "3|Author(s): ${lineArray[*]}" | sed 's/by //;s/<[^>]*>//g' ### Parsing additional data. elif [ "${lineArray[0]}" == "<li" ] && [ "$(echo ${lineArray[*]} | grep -ve "bullet" -ve "title")" ]; then echo "1|${lineArray[*]}" | sed 's/<[^>]*>//g;s/:/: /;s/ / /' fi done | sort -ur | awk -F\| '{print $2}' | grep ":" } if [ "${#ISBN}" -ge "10" ]; then fetchInfo fi |
The script should be saved to a file and called as ./isbn.sh
owen@linuxblog:~$ isbn.sh 1593275676 Title: How Linux Works: What Every Superuser Should Know by Brian Ward |
Here is ISBN Data Mining – Part 2 although, I cannot guarantee that it works after 8 years.