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:
Find the URL for each ISBN
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...