Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bs4, requests
- def getAmazonPrice(productUrl):
- req = requests.get(productUrl)
- try:
- req.raise_for_status()
- except:
- return None
- soup = bs4.BeautifulSoup(req.text,'html.parser')
- elem = soup.select('#unqualifiedBuyBox > div:nth-of-type(1) > div:nth-of-type(1) > span:nth-of-type(2)')
- assert len(elem) >= 1
- return elem[0].text.strip()
- price = getAmazonPrice('https://www.amazon.com.br/TABLET-SAMSUNG-TAB-T585-16GB/dp/B01G4618ZY/ref=sr_1_1?s=computers&ie=UTF8&qid=1516316045&sr=1-1')
- print('The price is: '+price)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement