def changestock(newvalue, filee): counter = 0 filecontents = [] f = open("Funkodb" + "/" + filee, "r") filecontents = f.read().split() f.close() f = open("Funkodb" + "/" + filee, "w") for a in filecontents: if a == "True" or a == "False": f.write(str(newvalue) + " ") else: f.write(a + " ") f.close() url = filee.replace("{slashhere}", "/").replace(".txt", "") discordmsg.send("stock has been updated to: " + str(newvalue).replace( "True", "in Stock").replace("False", "Not available in stock :-(") + " on " + filee.replace("{slashhere}", "/").replace(".txt", "")) try: discordtwo.sendproppermesage( url, url.replace("https://www.target.com", ""), get_price(url) + " $\n " + " __Stock: False__\n Site: Target ", "update", get_price(url) + " $\n " + " __Stock: False__\n Site: Target ", url) except: pass
def changeprice(newprice, filee): counter = 0 filecontents = [] f = open("Funkodb" + "/" + filee, "r") filecontents = f.read().split() f.close() f = open("Funkodb" + "/" + filee, "w") for a in filecontents: try: float(a) f.write(newprice + " ") except: f.write(a + " ") url = filee.replace("{slashhere}", "/").replace(".txt", "") discordmsg.send("price has been updated to: $" + newprice + " on " + filee.replace("{slashhere}", "/").replace(".txt", "")) try: discordtwo.sendproppermesage( url, url.replace("https://www.target.com", ""), newprice + " $\n " + " __Stock: False__\n Site: Target ", "update", newprice + " $\n " + " __Stock: False__\n Site: Target ", url) except: pass f.close()
def savefunko(funkodoll): print( os.path.isfile( "Funkodb/" + funkodoll.url.replace(" ", "").replace("/", "{slashhere}") + ".txt")) if (False == (os.path.isfile( "Funkodb/" + funkodoll.url.replace(" ", "").replace("/", "{slashhere}") + ".txt"))): f = open( "Funkodb/" + funkodoll.url.replace(" ", "").replace("/", "{slashhere}") + ".txt", "w") f.write(funkodoll.url + " Price " + funkodoll.price + " stockstate = " + str(funkodoll.inStock)) f.close() discordmsg.send("New Product found " + funkodoll.url)
def priceincreasealert(product): discordmsg.send(product.name + " has increased price url : " + product.url)
def pricedecreasealert(product): discordmsg.send(product.name + " is now on sale url : " + product.url)
def outofstockalert(product): discordmsg.send(product.name + " is now out of stock url : " + product.url)
def instockalert(product): discordmsg.send(product.name + " is now in stock url : " + product.url)
def newproductalert(product): discordmsg.send("new product found" + product.name + " url : " + product.url)
from urllib.request import urlopen as uReq import requests import os import bs4 from bs4 import BeautifulSoup as soup import csv import dryscrape import re import discordmsg discordmsg.send("target monitor started") nineteen = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ] discordinfo = "" discordinfo2 = "" databasename = "targetdatabase3.csv" databasetextname = "tDatabase" print(os.listdir("tDatabase")) class Product: stockqty = "" pid = "" name = "" price = "" url = "" inStock = False imgurl = "" f = "" def get_price(self):