Skip to content

Instantly share code, notes, and snippets.

@yarwelp
Last active August 29, 2015 14:24
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 yarwelp/03a04741d6fa1f43a96a to your computer and use it in GitHub Desktop.
Save yarwelp/03a04741d6fa1f43a96a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
curl "$1" 2>/dev/null \
| xmlstarlet fo -H --omit-decl 2>/dev/null \
| xmlstarlet sel -H -t -v "//*[@class='digital-product ']/@data-product-id" 2>/dev/null
echo
@yarwelp
Copy link
Author

yarwelp commented Jul 2, 2015

Ugly extraction of product id out of Packt Publishing ugly HTML. Example:

./packtpub-id.bash https://www.packtpub.com/game-development/webgl-beginners-guide

9977

I use these ID's in the catalog listing at http://www.erikano.net/eBooks/given-to-me.htm for books I have gotten through https://www.packtpub.com/packt/offers/free-learning.

The ID is also present in the "My eBooks" section of Packt Publishing so from now on, I type the ID manually. The script made it a bit easier to add ID's for books I had already listed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment