Advertisement
Guest User

Untitled

a guest
Oct 14th, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import requests, bs4
  2.  
  3. def getAmazonPrice(productUrl):
  4.     res = requests.get(productUrl)
  5.     res.raise_for_status()
  6.    
  7.     soup = bs4.BeautifulSoup(res.text,'html.parser')
  8.     elems = soup.select('#newOfferAccordionRow > div > a > h5 > div > div.a-column.a-span7.a-text-right.a-span-last > span.a-size-medium.a-color-price.header-price')
  9.     return elems[0].text.strip()
  10.  
  11. price = getAmazonPrice('http://www.amazon.com/Automate-Boring-Stuff-Python-Programming/dp/1593275994/ref=sr_1_1?ie=UTF8&qid=1444714975&sr=8-1&keywords=automate+python')
  12. print 'The price is ' + price
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement