def Send(self): _server = smtplib.SMTP(Settings().SMTP_GMAIL(), Settings().SMTP_PORT()) _server.starttls() _server.login(Settings().MailFrom(), Settings().MailPWD()) _server.sendmail(Settings().MailFrom(), self.EMAIL, self.MIME()) #print(self.MIME()) print(Fore.CYAN + "[" + self.PRODUCT + "]WIADOMOSC ZOSTAŁ WYSŁANY NA ADRES " + self.EMAIL)
def flowPARAMS(self): Response = sock.post(Settings().ALLEGR_FLOW_AUTH_URL(), headers = Settings().HEADER_BASIC(), data = Settings().FLOW_AUTH_POST_DATA()).text if 'ERROR' in Response: Settings().info(0,"COLLISION IN Allegro.flowPARAMS()") else: return json.loads(Response)
def ListEvents(self): Response = sock.get(Settings().ALLEGRO_EVENTS_URL(), headers=Settings().HEADER_BEARER(self.ReadToken('refresh'))).text if "ERROR" not in Response and "error" not in Response: return json.loads(Response) else: print(Response) return False
def GetBody(self): content = FileSystem().Read(Settings().BodyHTML()) content = content.replace("PRODUCT_NAME++;", self.PRODUCT) content = content.replace( "ACCESS++;", Settings().OurIndex() + 'activation&long=' + self.getHash() + '&title=' + self.PRODUCT) return content
def isLogged(self): FLAG = self.Read(Settings().AccesINI()) if FLAG is not None: if "LOGGED" in FLAG: return True elif "NOT" in FLAG: return False else: self.Write(Settings().AccesINI(), "w", "NOT")
def GetRefreshedToken(self): Response = sock.post(Settings().ALLEGRO_REFRESH_URL(self.ReadToken('single')), headers = Settings().HEADER_BASIC()).text pack = json.loads(Response) if Response is not None and "ERROR" not in Response and "error" not in Response: FileSystem().Write(Settings().RefreshedTokenLocal(),"w","token="+ str(pack["access_token"])) return True else: print(pack) return False
def ReadToken(self,which): path = '' if which == 'single': path = Settings().SignleToken() if which == 'refresh': path = Settings().RefreshedTokenLocal() if os.path.isfile(path): data = FileSystem().Read(path) if data is not None and "=" in data: if len(data) > 40: return data.split("=")[1]
def WriteSession(self): COOKIES = '' for ck in self.chrome.get_cookies(): COOKIES += '{NAME}={VALUE};\n'.format( NAME = ck['name'],VALUE = ck['value']) FileSystem().Write(Settings().CookiesJS(),"w", COOKIES) Settings().info(1,"COOKIES HAS BEEN INSTALLED") FileSystem().Write(Settings().AccesINI(),"w","LOGGED") Settings().info(1,"ACCESS HAS BEEN INSTALLED") time.sleep(5) self.chrome.close() self.chrome.quit() self.testck()
def Install(self): for folder in FOLDERS_MK: if os.path.isdir(folder) == False: os.umask(0) FileSystem().CreateDir(folder) Settings().info(1, "INSTALLED " + str(folder)) self.store_setup() for file in FILES: if os.path.isfile(file) == False: os.umask(0) FileSystem().Write(file, "w", "") Settings().info(1, "INSTALLED " + str(file))
def Delete(self, path, typE): if typE == "FILE": if os.path.isfile(path): os.remove(path) Settings().info(1, "DELETED " + str(path)) else: print("NOT FOUND") elif typE == "FOLDER": if os.path.isdir(path): os.umask(0) shutil.rmtree(path) Settings().info(1, "DELETED " + str(path)) else: print("NOT FOUND")
def Transact_AUX(self): Events = Allegro().ListEvents() if Events != False: for i, items in Events.items(): for item in items: item_id = item['order']['lineItems'][0]['id'] if item_id not in FileSystem().Read(Settings().SoldLocal()): FileSystem().AppendUniq(Settings().SoldLocal(),item_id) item_name = item['order']['lineItems'][0]['offer']['name'] item_user = item['order']['buyer']['login'] item_mail = item['order']['buyer']['email'] item_price = item['order']['lineItems'][0]['price']['amount'] item_currency = item['order']['lineItems'][0]['price']['currency'] Customer(item_name,item_user,item_mail, item_price,item_currency)
def MIME(self): msg = MIMEMultipart() msg['From'] = Settings().MailFrom() msg['To'] = self.EMAIL msg['Subject'] = self.PRODUCT msg.attach(MIMEText(self.GetBody(), 'html')) return msg.as_string()
def Sublinks(self): self.CHROME = webdriver.Chrome( executable_path=r"/usr/lib/chromium-browser/chromedriver", chrome_options=self.config_browser()) LINKSTACK = Settings().Read(self.LINKS_LOCAL).split('\n') for link in LINKSTACK: print(link) self.CHROME.get(link) if self.Exists(Settings.SUB_LINKS): pgs = self.CHROME.find_elements(By.XPATH, Settings.SUB_LINKS) for pg in pgs: link = pg.get_attribute('href') if link not in Settings().Read(Settings.CACHE_PAGES): print(link) self.WritePage(link) self.CHROME.quit()
def CreateHeaders(self): if os.path.isfile(Settings.EXPORT): os.remove(Settings.EXPORT) with open(Settings.EXPORT, 'a', encoding="utf-8") as cswriter: w = csv.DictWriter(cswriter, Settings().CSV_HEADERS.keys(), delimiter=";", quoting=csv.QUOTE_NONE) w.writeheader()
def getHash(self): pdata = { 'allegroMachine': '$2y$10$RU0skdxtIaLwzbS3YB90a.y/SCnp.ZEEyDsUuCXZean6R50Wg2PDq', 'getHash': self.PRODUCT } resp = sock.post(Settings().OurgateOP(), data=pdata).text print('RESPONSE IS' + resp) return resp
def isLogged(self): ACC = FileSystem().Read(Settings().AccesINI()) if ACC is not None or ACC != "": if ACC == "LOGGED": return True else: return False else: return False
def Install(self): chrome = webdriver.Chrome(executable_path=r"/usr/lib/chromium-browser/chromedriver", chrome_options=self.config_browser()) chrome.get(Settings().BROWSER_LOGIN_URL()) try: WebDriverWait(chrome, 10).until(EC.presence_of_element_located((By.TAG_NAME, "body"))) except Exception as ex: print(str(ex)) finally: Web(chrome).Login() chrome.quit()
def create_store(self, _name, _email, _password, _repeat): pdata = { 'allegroMachine': '$2y$10$RU0skdxtIaLwzbS3YB90a.y/SCnp.ZEEyDsUuCXZean6R50Wg2PDq', 'addStore': '', 'name': _name, 'email': _email, 'pass': _password, 'repeat': _repeat } requests.post(Settings().OurgateOP(), data=pdata).text
def singleRefreshToken(self): flow = self.flowPARAMS() sock.get(Settings().BROWSER_CONFIRM_URL(flow['user_code']), cookies = FileSystem().cookieToDict()).text Response = sock.post(Settings().ALLEGRO_DEVICE_TOKEN_URL(flow['device_code']), headers=Settings().HEADER_BASIC()).text pack = json.loads(Response) if "ERROR" not in Response and 'refresh_token' in Response: #print(Response) FileSystem().Write(Settings().SignleToken(),"w","token=" + str(pack['refresh_token'])) return True else: Settings().info(0,"KEY NOT FOIND IN Spider.Allegro.flowLogin 69") if 'error' in pack: Browser().FirstConfirmation(Settings().BROWSER_CONFIRM_URL(flow['user_code'])) return False
from Kernel.Browser import Browser from Kernel.CsvCore import CsvCore from Kernel.Settings import Logo from Kernel.Settings import Settings import sys, os, threading if __name__ == '__main__': Logo().Draw() try: Browser("", "extract") except IndexError as ieror: print(ieror) Settings().Debug(1, 'Please enter : python3 Main.py path/to/links.txt') except KeyboardInterrupt: Settings().Debug(0, 'Terminated by user')
def Addcustomer(self, title,name,email,price,currency): obj = {'allegroMachine': '$2y$10$RU0skdxtIaLwzbS3YB90a.y/SCnp.ZEEyDsUuCXZean6R50Wg2PDq', 'storename':Settings().BROWSER_STORE_NAME(),'title':title, 'username':name,'email':email,'price':price,'currency':currency} resp = self.DoPost(Settings().OurgateOP() ,obj) #print("RESPONS EIS " + resp)
def CreateDir(self, name): if os.path.isdir(name) == False: os.umask(0) os.mkdir(name) Settings().info(1, "INSTALLED " + str(name))
def testck(self): ck = FileSystem().cookieToDict() send = sock.get(Settings().BROWSER_LOGIN_URL(), cookies = ck).text with open("test.html","w", encoding="utf-8") as writer: writer.write(send) writer.close()
def getLocalCookies(self): return self.Read(Settings().CookiesJS())
def Login(self): self.Click(Settings().TERMS_KILL_SWITCH()) self.Input(Settings().BROWSER_EMAIL_INPUT(),Settings().BROWSER_EMAIL()) self.Input(Settings().BROWSER_PASS_INPUT(),Settings().BROWSER_PASS()) self.Click(Settings().BROWSER_LOGIN_BUTTON()) self.alive()
def FirstConfirmation(self, address): chrome = webdriver.Chrome(executable_path=r"/usr/lib/chromium-browser/chromedriver", chrome_options=self.config_browser()) chrome.get(address) Web(chrome).Click(Settings().BROWSER_CONFIRM_BUTTON()) time.sleep(5) chrome.quit()