0%

Compare iPhone Price

Please following the core code or clone the project from Github

1
2
3
4
5
6
7
8
9
10
11
12
def getPrice(country):
url = "https://www.apple.com/" + country + "/shop/buy-iphone/iphone-8/"
resp = request.urlopen(url)
html_data = resp.read().decode('utf-8')
soup = bs(html_data.lower(), 'html.parser')
url_data = soup.script.string
for item in json.loads(url_data)['offers']:
sku = item['sku']
if (re.search('mq6', sku)):
price = item['price']
pricecurrency = item['pricecurrency']
print(sku + ": " + str(price) + " " + pricecurrency)