Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- import requests
- import os
- url_base = 'https://www.beephone.fr/iphone-reconditionne/'
- cmd = '/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser '
- class Product:
- def __init__(self, name, colors, sizes):
- self.name = name
- self.colors = colors
- self.sizes = sizes
- def notify(title, text):
- os.system("""
- osascript -e 'display notification "{}" with title "{}"'
- """.format(text, title))
- av_delays = list()
- products_objects = [Product("7", ["noir", "argent", "or", "or-rose"], ["-32-go", "-128-go"]),
- Product("7-plus", ["noir", "argent", "or", "or-rose"], ["-32-go", "-128-go", "-256-go"]),
- Product("8", ["gris-sideral", "argent", "or"], ["-64-go"]),
- Product("8-plus", ["gris-sideral", "argent", "or"], ["-64-go"]),
- Product("x", ["gris-sideral", "argent"], ["-64-go", "-256-go"]),
- Product("xr", ["noir", "blanc"], ["-64-go", "-128-go", "-256-go"])]
- prices = ['255,00 €', '268,00 €', '259,00 €', '279,00 €', '255,00 €', '278,00 €', '255,00 €', '279,00 €', '350,00 €', '375,00 €', '395,00 €', '350,00 €', '370,00 €', '395,00 €', '355,00 €', '370,00 €', '395,00 €', '350,00 €', '370,00 €', '395,00 €', '359,00 €', '355,00 €', '350,00 €', '470,00 €', '465,00 €', '470,00 €', '570,00 €', '650,00 €', '580,00 €', '660,00 €', '600,00 €', '640,00 €', '670,00 €', '610,00 €', '650,00 €']
- while(1):
- delays = list()
- for product in products_objects:
- for color in product.colors:
- for size in product.sizes:
- response = requests.get(url_base + "iphone-" + product.name + "/" + color + size + "/")
- delays.append(response.elapsed.total_seconds())
- if response.status_code == 200:
- soup = BeautifulSoup(response.text, features="lxml")
- priceElmt = soup.find('h2',{'id':'gradePrice'})
- if(priceElmt):
- price = priceElmt.text
- if price != '':
- print("iPhone " + product.name + " " + color + size + " : " + price)
- if price == '1,00 €' or price == '0,99 €' or price not in prices:
- notify("PROMO TROUVÉE", "iPhone " + product.name + " " + color + size)
- os.system(cmd + url_base + "iphone-" + product.name + "/" + color + size + "/")
- av_delay = round(sum(delays)/len(delays)*1000, 0)
- print("-----Average delay : " + str(av_delay) + " ms-----")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement