Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Getting Started with Beautiful Soup

You're reading from   Getting Started with Beautiful Soup Learn how to extract information from websites using Beautiful Soup and the Python urllib2 module. This practical, hands-on guide covers everything you need to know to get a head start in website scraping.

Arrow left icon
Product type Paperback
Published in Jan 2014
Publisher Packt
ISBN-13 9781783289554
Length 130 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Vineeth G Nair Vineeth G Nair
Author Profile Icon Vineeth G Nair
Vineeth G Nair
Arrow right icon
View More author details
Toc

Getting the selling price from Barnes and Noble


We have to use the same strategy we used for Amazon to find the selling price on the Barnes and Noble website. For this, we need to perform the following steps:

  1. Find the URL for each ISBN

  2. Find a way to scrape the selling price

The URL that can be used for Barnes and Noble is http://www.barnesandnoble.com/s/ISBN, where ISBN is the ISBN value, for example, http://www.barnesandnoble.com/s/1904811590).

Now, we have to find the selling price from the page. The page at Barnes and Noble will have the selling price listed in a div tag with the price class (highlighted) in the following screenshot:

We can find the selling price from Barnes and Noble using the following code:

def get_sellingprice_barnes(isbn):
  url_forbarnes = http://www.barnesandnoble.com/s/
  url_for_isbn_inbarnes = url_forbarnes+isbn
  page = urllib2.urlopen(url_for_isbn_inbarnes,"lxml")
  soup_barnes = BeautifulSoup(page,"lxml")
  page.close()
  selling_price_tag = soup_barnes.find('div...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime