def  update_items_sheet(self):
		self.items = self.sheet.col_values(self.items_colm)[1:]
		amazon_bot = AmazonBot(self.items)
		urls, prices, name_of_items = amazon_bot.search_items()

		print("\nUpdating the Spreadsheet.....\n")
		for x in range(len(urls)):
			self.sheet.update_cell(x+2, self.price_colm, prices[x])
			self.sheet.update_cell(x+2, self.prod_url, urls[x])
			self.sheet.update_cell(x+2, self.prod_name, name_of_items[x])
    def process_item_list(self):
        items = self.sheet.col_values(self.item_col)[1:]
        amazon_box = AmazonBot(items)
        prices, urls, names = amazon_box.search_items()

        print("Updating spreedsheet.")
        for i in range(len(prices)):
            self.sheet.update_cell(i + 2, self.price_col, prices[i])
            self.sheet.update_cell(i + 2, self.url_col, urls[i])
            self.sheet.update_cell(i + 2, self.product_name_col, names[i])
    def process_item_list(self):
        # Skip over the column heading in the spreadsheet.
        items = self.sheet.col_values(self.item_col)[1:]
        print(items)

        amazon_bot = AmazonBot(items)
        prices, urls, names = amazon_bot.search_items()

        print("Updating spreadsheet.")
        print(prices, urls, names)

        for i in range(len(prices)):
            self.sheet.update_cell(i + 2, self.price_col, prices[i])
            self.sheet.update_cell(i + 2, self.url_col, urls[i])
            self.sheet.update_cell(i + 2, self.product_name_col, names[i])
Exemple #4
0
    def update_spreadsheet_price(self):
        urls = self.sheet.col_values(self.url_col)

        for i in range(1, len(urls)):
            print(f"Processing URL {i} or {len(urls)-1}")
            amazon_bot = AmazonBot(urls[i])
            product_name = amazon_bot.get_product_name()
            product_price = amazon_bot.get_product_price()

            print(
                f"Updating item {self.sheet.cell(i+1, self.item_col).value} from Amazon listing {product_name} with price {product_price}"
            )
            self.sheet.update_cell(i + 1, self.price_col, product_price)
            amazon_bot.close_session()
Exemple #5
0
        "mongodb+srv://" + os.getenv("MONGODB_USERNAME") +
        ":" + os.getenv("MONGODB_PASSWORD") + "@" + os.getenv("MONGODB_DOMAIN") +
        "/" + os.getenv("MONGODB_DBNAME") + "?retryWrites=true&w=majority"
    )
    client.server_info()
except Exception as e:
    raise e

# Connexion au serveur pour l'envoi d'email
try:
    context = ssl.create_default_context()
    server = smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context)
    server.login(os.getenv("SENDER_EMAIL"), os.getenv("EMAIL_PASSWORD"))
except Exception as e:
    raise e

# Initialisation de la classe AmazonBot
bot = AmazonBot(mongodb_client=client, server_smtp=server)
# Lancement du Scraping
bot.scrap_urls()

# Liste des produits Amazon

# product_urls = [
#     "https://www.amazon.fr/Apple-AirPods-bo%C3%AEtier-charge-Dernier/dp/B07PZR3PVB/ref=sr_1_5?__mk_fr_FR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&dchild=1&keywords=airpod&qid=1610634324&sr=8-5",
#     "https://www.amazon.fr/PlayStation-%C3%89dition-Standard-DualSense-Couleur/dp/B08H93ZRK9/ref=sr_1_1?__mk_fr_FR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=OC9DXXI5NXTR&dchild=1&keywords=playstation+5&qid=1610634362&sprefix=playstatio%2Caps%2C204&sr=8-1",
#     "https://www.amazon.fr/Nintendo-Switch-avec-paire-Rouge/dp/B07WKNQ8JT/ref=zg_bs_videogames_home_1?_encoding=UTF8&psc=1&refRID=NXGE6WDBSEDAVF5CS2AA",
#     "https://www.amazon.fr/T12S-Transformation-semaines-minutes-d%C3%A9finitivement/dp/2035999642/ref=zg_bsnr_books_home_1?_encoding=UTF8&psc=1&refRID=71P5R2S30WR2EPDRPAP7",
#     "https://www.amazon.fr/chronique-Bridgerton-Tomes-Julia-Quinn/dp/2290254738/ref=zg_bsnr_books_home_3?_encoding=UTF8&psc=1&refRID=71P5R2S30WR2EPDRPAP7",
# ]
                + firefox_config_key + "].")
            sys.exit(1)
    else:
        print("Could not find the [" + firefox_config_key +
              "] config section. Exiting...")

    # Launch one of the bot types.
    if parser.parse_args().bot_type == amazon_bot_type_val:
        print("Launching the '" + amazon_bot_type_val + "' bot type.")
        # Parse the amazon configuration
        if amazon_config_key in config:
            try:
                amazon_credentials = AmazonCredentials(
                    config[amazon_config_key]['username'],
                    config[amazon_config_key]['password'])
                store_url = config[amazon_config_key]['storeUrl']
            except KeyError:
                print(
                    "Missing 'username', 'password' or 'storeUrl' keywords from the ["
                    + amazon_config_key + "] config section.")
                sys.exit(1)
        else:
            print("Could not find the [" + amazon_config_key +
                  "] config section. Exiting...")
            sys.exit(1)

        # Launch the amazon bot.
        amazon_bot = AmazonBot(twilio_client_wrapper, firefox_profile_path,
                               amazon_credentials, store_url)
        #amazon_bot.login_attempt()
        #amazon_bot.finding_cards()