def registersymbols(self, feedtype="TOS", output="bytype"): print("Starting THREADS to register L1 AND TOS for Symbol List") for record, symbol in self.symbols.items(): print(symbol + " : "+feedtype+" : "+output) t = threading.Thread(target=self.registersymbol, args=(symbol, feedtype, output,)) t.start() pause.sleep(0.2)
def output_tweets(self, lang_code, query, filename, sent_counter, max_count=10): b_tweets_output = False try: tweets = self.search_tweets(lang_code, query, max_count) except twitter.api.TwitterHTTPError as er: # Local rate limit cache has probably got out of synch with Twitter print("TwitterHTTPError: " + str(er)) self.synchronise_rate_limit() # Re-synchronise and retry tweets = self.search_tweets(lang_code, query, max_count) except (urllib2.URLError, httplib.BadStatusLine) as er: # Connection dropped print("Connection error: " + str(er)) pause.sleep(15) # Sleep 15 seconds and retry try: tweets = self.search_tweets(lang_code, query, max_count) except urllib2.URLError as er: print("Connection error: " + str(er)) pause.sleep(30) # Sleep 30 seconds and retry again tweets = self.search_tweets(lang_code, query, max_count) f = codecs.open(filename, 'a', encoding='utf-8', errors='replace') for status in tweets['statuses']: status_str = MyTwitterBase.status_to_string(status, False, False) if status_str is not None: if query.lower() in status_str.lower(): tokens = self.tokenizer.tokenize(status_str) # print(status_str) b_tweets_output = True #f.write(query + ' ||| ' + status_str + '\n') f.write(lang_code + str(sent_counter) + '\t' + ' '.join(tokens).lower() + '\n') sent_counter += 1 f.close() return [b_tweets_output, sent_counter]
def add_cctv(site_name, cctv_name, cctv_number, cctv_address, cctv_area_index): cctv_add = wait.until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[2]/main/div/div/div[2]/a'))) cctv_add.click() cctv_site_name = wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@id="siteId_fake"]'))) cctv_site_name.click() cctv_site_search = wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@id="search_siteId"]'))) cctv_site_search.send_keys(site_name) cctv_site_search_ok = driver.find_element_by_xpath('/html/body/div[3]/div/div[1]/div[1]/div/div/div/div/button[1]') cctv_site_search_ok.click() pause.sleep(3) cctv_site_check = wait.until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[3]/div/div[1]/div[2]/table/tbody/tr[1]/td[1]'))) cctv_site_check.click() cctv_site_ok = driver.find_element_by_xpath('//*[@id="search_modal_success_btn"]') cctv_site_ok.click() pause.sleep(0.3) cctv_area_dropdown = Select(driver.find_element_by_xpath('//*[@id="areaId"]')) cctv_area_dropdown.select_by_visible_text(cctv_name) cctv_name_label = driver.find_element_by_xpath('//*[@id="cctvName"]') cctv_name_label.send_keys(cctv_name) # if len(cctv_number) == 1: # cctv_number = "0" + cctv_number # cctv_address = str(cctv_address) + str(cctv_number) + "_rec" cctv_address = str(cctv_address) + str(cctv_number) cctv_address_label = driver.find_element_by_xpath('//*[@id="cctvAddress"]') cctv_address_label.send_keys(cctv_address) cctv_area_register = driver.find_element_by_xpath('//*[@id="btn_reigster"]') cctv_area_register.click() cctv_area_register_ok = driver.find_element_by_xpath('//*[@id="confirm_register"]/div/div/button[1]') cctv_area_register_ok.click() print(site_name + " [" + cctv_name + "] 입력 완료.") return
def register_eure_time_of_sale(self): currentdate = datetime.now() print(currentdate.year.__str__() + currentdate.month.__str__() + currentdate.day.__str__()) # pause.until(datetime(currentdate.year, currentdate.month, currentdate.day, 11, 0, 0, 0)) eurexsymbols = EuropeanClosing("C:\\logs\\Milan.csv") eurexsymbols.registersymbols() pause.sleep(3) eurexsymbols = EuropeanClosing("C:\\logs\\Amsterdam.csv") eurexsymbols.registersymbols() pause.sleep(3) eurexsymbols = EuropeanClosing("C:\\logs\\Brussels.csv") eurexsymbols.registersymbols() pause.sleep(3) eurexsymbols = EuropeanClosing("C:\\logs\\Lisbon.csv") eurexsymbols.registersymbols() pause.sleep(3) eurexsymbols = EuropeanClosing("C:\\logs\\Paris.csv") eurexsymbols.registersymbols()
prices = [] for book in book_container: ranks.append(book.div.div.text) titles.append(book.div.h3.a.text) authors.append( book.find('div', class_='product-shelf-author contributors').text) dates.append(book.div.h3.span.text) prices.append( book.find( 'div', class_='product-shelf-pricing mt-s mb-s').tbody.tr.span.a.text) if page < pageCap: for index, book in enumerate(book_container): print("Rank: " + ranks[index]) print("Title: " + titles[index]) print("\t" + authors[index]) print("Published: " + dates[index]) print("Price: " + prices[index] + "\n") else: for index in range(0, pageRem): print("Rank: " + ranks[index]) print("Title: " + titles[index]) print("\t" + authors[index]) print("Published: " + dates[index]) print("Price: " + prices[index] + "\n") # Pause retrieving info from website so servers don't get strained pause.sleep(2)
to = "*****@*****.**" sendEmail(to, content) speak("Email has been sent!") except Exception as e: print(e) speak("Sorry sir. I am not able to send this email") elif 'email to father' in query: try: speak("What should I say?") content = takeCommand() to = "*****@*****.**" sendEmail(to, content) speak("Email has been sent!") except Exception as e: print(e) speak("Sorry sir. I am not able to send this email") elif 'wait' in query: if 'wait' in query: sleep = int(input('Till how much I will wait:')) wait = pause.sleep(sleep) elif 'quit' in query: speak('Ok sir bye bye') quit() elif 'exit' in query: speak('Ok sir shuting down the system') exit()
isExit = False isEntrance_Exit = False d.site_name = l[0] d.address = l[1][:-6] d.entrance = l[2] d.exit = l[3] d.entrance_exit = l[4] d.index_array = list() site_search = wait.until( EC.element_to_be_clickable( (By.XPATH, '//*[@id="schKeyword_siteAll"]'))) site_search.send_keys(d.site_name) site_search.send_keys(Keys.ENTER) pause.sleep(0.5) try: site_list_item = wait.until( EC.element_to_be_clickable( (By.XPATH, '/html/body/div[2]/main/div/div/div[2]/div[1]/div[2]/a'))) site_list_item.click() print(d.site_name, ", ", site_list_item.text) except Exception: print(d.site_name + "에서 문제 발생. 해당 사이트 없음.") errorlist.append(d.site_name) continue f.close()
# URL = "https://www.eventbrite.co.uk/e/hackhack-tickets" # URL = "https://www.eventbrite.co.uk/e/hack1040-tickets" # URL = "https://www.eventbrite.co.uk/e/test-tickets" URL = "https://www.eventbrite.co.uk/e/ic-hack-20-tickets" # LAUNCH = datetime(2020, 1, 10, 13, 30, 0, 100000) LAUNCH = datetime(2020, 1, 10, 13, 29, 59, 100000) REG_X, REG_Y = 600, 750 def click_select(n): move(X, Y + n * DELTA_Y) click() driver = webdriver.Chrome() until(LAUNCH) s = timeit.default_timer() driver.get(URL + TICKET_ID) load = timeit.default_timer() reg1 = driver.find_element_by_id("eventbrite-widget-modal-trigger" + TICKET_ID) reg1.click() sleep(2) click_select(0) press_and_release("down") press_and_release("enter") sleep(1) move(REG_X, REG_Y) click() e = timeit.default_timer() print(load - s) print(e - load)
isEntrance_Exit = False d.site_name = l[0] d.address = l[1] d.entrance = l[2] d.exit = l[3] d.entrance_exit = l[4] d.index_array = list() #print(d.address) site_search = wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@id="schKeyword_siteAll"]'))) site_search.clear() site_search.send_keys(d.site_name) site_search.send_keys(Keys.ENTER) pause.sleep(0.5) try: site_list_item = wait.until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[2]/main/div/div/div[2]/div[1]/div[2]/a'))) site_list_item.click() # if d.site_name == site_list_item.text: # print(d.site_name,",", site_list_item.text) # else: # print('[ERR] 불일치 : ', d.site_name, site_list_item.text) except Exception: print(d.site_name+"에서 문제 발생. 해당 사이트 없음.") errorlist.append(d.site_name) continue