def watchStories(self): try: self.browser.find_elements_by_class_name('OE3OK')[0].click() print("watching stories") wait(60, 90) self.browser.find_elements_by_class_name('-jHC6')[0].click() print("finished watching stories") except Exception as e: print(e)
def __init__(self): self.creds, self.accs, self.comments = config() self.browser = webdriver.Chrome( executable_path='/usr/local/bin/chromedriver') #TODO make own ActionChains Manager Class self.browser.get( "https://www.instagram.com/accounts/login/?source=auth_switcher") wait(2, 5) self.login() self.actions = ActionChains(self.browser)
def likePost(self): for post in self.browser.find_element_by_class_name( 'fr66n').find_elements_by_css_selector("*"): if (post.get_attribute("class") == '_8-yf5 '): if (post.get_attribute("fill") == '#ed4956'): break else: self.browser.find_element_by_class_name( 'fr66n').click() # like break wait(4, 8)
def tryFollow(self): wait(3, 5) for button in self.browser.find_elements_by_tag_name("button"): if (type(button.text) is not str): print('not string') continue if (button.text == 'Requested' or button.text == 'Following'): print('already following') break if (button.text == 'Follow' or button.text == 'Follow Back'): button.click() break wait(5, 8)
def login(self): self.insert(self.browser.find_element_by_name("username"), self.creds[0]) wait(2, 5) pw = self.browser.find_element_by_name("password") pw.click() self.insert(pw, self.creds[1]) wait(2, 5) pw.send_keys(Keys.ENTER) self.browser.maximize_window() wait(5, 8) # no Save Login Info self.browser.find_element_by_class_name('sqdOP.L3NKy.y3zKF').click() wait(5, 8) # no notification push self.browser.find_element_by_class_name('aOOlW.HoLwm ').click() wait(8, 10)
def insertComment(self, user): comment = random.choice(self.comments) + ' ' if (randint(0, 2) == 0): comment = comment + '@' + user + ' ' commentField = self.browser.find_element_by_class_name('Ypffh') commentField.click() commentField = self.browser.find_element_by_class_name('Ypffh') for char in comment: wait(0.2, 0.6) commentField.send_keys(char) wait(5, 8) self.actions.send_keys(Keys.ENTER).perform() wait(5, 8) self.actions.send_keys(Keys.ESCAPE).perform() wait(5, 8) self.actions.reset_actions()
import numpy as np LoginUrl = "https://login.ticketmonster.co.kr/user/loginform?return_url=" ItemUrl = [ "https://www.ticketmonster.co.kr/deal/1156912910?keyword=%EC%8B%B1%EA%B0%80%ED%8F%AC%EB%A5%B4+%EC%9C%A0%EB%8B%88%EB%B2%84%EC%85%9C%EC%8A%A4%ED%8A%9C%EB%94%94%EC%98%A4&reason=er&etype=nm&useArtistchaiRegion=Y", "https://www.ticketmonster.co.kr/deal/1574650942?keyword=%EC%8B%B1%EA%B0%80%ED%8F%AC%EB%A5%B4+%EC%9C%A0%EB%8B%88%EB%B2%84%EC%85%9C%EC%8A%A4%ED%8A%9C%EB%94%94%EC%98%A4&reason=er&etype=nm&useArtistchaiRegion=Y" ] driver = webdriver.Chrome('/Users/user/PycharmProjects/MakePerson/tm/buyer/chromedriver') timeStap = [] for Num in range(12,16,1): driver.get(cd.company_code['login_url']) fc.login(driver , ac.tm_acoountsID[Num] , ac.tm_acoountsPAW[Num]) #첫번쨰 싱가포르 유니버셜 driver.get(ItemUrl[0]) fc.reservation(driver , 9) fc.order(driver , ac.tm_acoountsLname[Num] , ac.tm_acoountsFname[Num] , "*****@*****.**" , str(5)) fc.wait(driver) time = datetime.datetime.now() timeStap.append(time) fc.logout(driver) print(timeStap)
def display_table_custom(screen): # hw.do_the_work_customized() # here you create all the initialization values for the class that will display the table f.wait(1) return "new_table"
def parseThroughAccounts(self): print(self.accs) for acc in self.accs: if os.path.isdir(c.ROOT_URL + 'accounts/' + acc) : continue users = set() self.searchUser(acc) self.browser.find_elements_by_class_name('-nal3')[1].click() wait(2,5) self.browser.find_element_by_class_name('PZuss').click() # Click into div to enable Spacebar scrolling; IG blocks instantly; click div again to enable Spacebar wait(5,8) self.actions.send_keys(' ').perform() self.actions.reset_actions() wait(2,5) self.browser.find_element_by_class_name('PZuss').click() # div element - scrolling area t_end = time.time() + randint(1200000, 1500000)/10000 #scrolling simulation in seconds 2 - 2.5 minutes while time.time() < t_end: if(randint(1,8) == 1): wait(5,10) wait(0.3,0.8) self.actions.send_keys(' ').perform() self.actions.reset_actions() for user in self.browser.find_elements_by_class_name("FPmhX.notranslate._0imsa"): users.add(user.text) self.browser.get("https://www.instagram.com/") if (not os.path.isdir(c.ROOT_URL + 'accounts/' + acc)) : os.mkdir(c.ROOT_URL + 'accounts/' + acc) with open(c.ROOT_URL + 'accounts/' + acc + '/' + acc + '_followers.csv', 'w') as file: for user in users: file.write(user) file.write('\n') with open(c.ROOT_URL + 'accounts/' + acc + '/' + acc + '_followed.csv', 'w') as file: print('followed file created') with open(c.ROOT_URL + 'accounts/' + acc + '/' + acc + '_not-followed.csv', 'w') as file: print('not followed file created') with open(c.ROOT_URL + 'accounts/' + acc + '/' + acc + '_private-requested.csv', 'w') as file: print('private requested file created') wait(10,20)
elif (('погода ' in text.lower()) or ('погоду ' in text.lower())): functions.weather(text) # elif ('календарь ' in text.lower()): if ('год ' in text.lower()): functions.showCalendar(True) else: # Month and everything else functions.showCalendar(False) # elif ('очисти ' in text.lower()) or ('сотри ' in text.lower()) or ('очистить ' in text.lower()): functions.os.system('cls') # elif ('подожди ' in text.lower()): functions.wait() # elif ('настроение ' in text.lower()) or (('как ' in text.lower()) and ('дела ' in text.lower())) or ( ('как ' in text.lower()) and ('жизнь ' in text.lower())): functions.mood() # elif ('найди ' in text.lower()) or ('загугли ' in text.lower()): functions.webSearch(text) # elif ('задач' in text.lower()): functions.taskManager(text) # elif ('повтори ' in text.lower()): functions.repeat(text)
def searchUser(self, user): search = self.browser.find_element_by_class_name("XTCLo.x3qfX") wait(2, 5) self.insert(search, user) wait(10, 12) try: # sometimes the exact user literal does not find the wanted user if (self.browser.find_element_by_class_name("Ap253").text != user): self.browser.get('https://www.instagram.com/' + user) wait(7, 12) return True self.browser.find_element_by_class_name("Ap253").click() wait(10, 14) return True except: wait(5, 8) self.browser.find_element_by_class_name( "aIYm8.coreSpriteSearchClear").click() wait(10, 15) return False
def insert(self, textField, _input): for char in _input: wait(0.15, 0.35) textField.send_keys(char)