0

I get a product link that is on Aliexpress then I want to get the product price value and print it. I like this:

import requests
import urllib2
import sys
import urllib.parse
import urllib.request
import re


from bs4 import BeautifulSoup as BS
url ="https://www.amazon.com/Optimum-Nutrition-Standard-Naturally-Flavored/dp/B00QQA0H3S?pd_rd_wg=Hiuuc&pd_rd_r=2542737c-992b-4b5c-b7de-05acce3929d5&pd_rd_w=be1cP&ref_=pd_gw_simh&pf_rd_r=WFBB3JV61PKGSDJRW0C1&pf_rd_p=b841581f-e864-5164-afa6-4c18a8348879"
usock = urllib2.urlopen(url)
data = usock.read()
usock.close()
soup = BS(data)
price = soup.findAll("span", {"id": "volume"})[0]
print price

In this Amazon link, I want to find the 55.01 value.(Amazon is a just example.The website does not matter.It may be AliExpress etc.)

Ali Göktaş
  • 15
  • 1
  • 7
  • price = soup.findAll("span", {"id": "priceblock_ourprice"})[0] – Pushplata May 13 '18 at 15:02
  • Possible duplicate of [How to use Selenium with Python?](https://stackoverflow.com/questions/17540971/how-to-use-selenium-with-python) – John May 13 '18 at 15:26
  • @John he doesn't use selenium, so that's not a duplicate – λuser May 13 '18 at 15:44
  • @OP you should probably change your user-agent to make them think you're a user browser, not a python browser. Also, you might switch to a real scraping framework that already does this kind of thing for you, like `weboob`. – λuser May 13 '18 at 15:48

0 Answers0