Skip to content

Instantly share code, notes, and snippets.

@captivus
Created April 26, 2020 17:29
Show Gist options
  • Save captivus/ad95aff06fdc639a659904bd5e70fe9c to your computer and use it in GitHub Desktop.
Save captivus/ad95aff06fdc639a659904bd5e70fe9c to your computer and use it in GitHub Desktop.
Parse Audible Matchmaker data into something mathematically useful ...
# find all of the spans containing the audiobook price
# (see accompanying Jupyter notebook for details)
upgrade_prices = soup.findAll(name='span', attrs={'class' : 'a-size-base a-color-price a-text-bold'})
# iterate over each of the book prices
for book in upgrade_prices:
# convert the span price data to a string
price_string = book.string
# remove the dollar sign from the price string
price_string = price_string.replace('$', '')
# convert the price string to a decimal number
price = float(price_string)
# add it to our running total
total_upgrade_price += price
# Donezo! What's it cost to buy all available Audible books?
print(total_upgrade_price)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment