def main(): skipTests = [ ] #['sequence_memory', 'chimp_test', 'aim_trainer', 'typing', 'verbal_memory', 'number_memory', 'visual_memory'] driver = Browser() dashURL = 'https://humanbenchmark.com/dashboard' driver.implicitly_wait(0.05) driver.go_to(dashURL) driver.click('Accept all') for i, test in enumerate(tests.get_tests(), 1): if test.__name__ in skipTests: print('Skipping:', test.__name__) continue print('Completing:', test.__name__) if driver.get_current_url() != dashURL: print('At incorrect page:', driver.get_current_url()) driver.go_to(dashURL) time.sleep(1) driver.click('Play', number=i) driver.click('Start') test(driver) time.sleep(0.2) driver.click('Save score') driver.implicitly_wait(0.05) driver.go_to(dashURL) #Keep browser open until user exit _ = input('Press enter to exit:')
def web_auth(auth_url, csrf_token, email, password): # Constants state_param = 'state=' code_param = 'code=' url_separator = '&' # Instantiate browser web = Browser() # Web authentication process web.go_to(auth_url) web.type(email, 'login') web.type(password, 'password') web.click('Authorize') web.click('Grant access to Box') # Get url for access code access_url = web.get_current_url() # Close browser web.close_current_tag() print("URL: " + access_url) # Get access codes access_csrf = access_url[access_url.index(state_param) + len(state_param):access_url.index(url_separator)] access_code = access_url[access_url.index(code_param) + len(code_param):] # Return access codes return access_csrf, access_code
for i in range(0,200,20): pyautogui.click(260, 375+i) #print("y = " + str(375+i)) #!!!!!!!!!!!!!!!!!!!!!!! #This is where we are stuck! Adding people to the hangout! because we can't do it with pyauto.gui since the location to add files is too small. :( . Probably need to inspect element this. #!!!!!!!!!!!!!!!!! for i in range(0,200,20): pyautogui.click(460, 290+i) pyautogui.click(260, 230) whichCall = groupName + str(totalGroups); web.type(whichCall) pyautogui.click(440, 260) pyautogui.click(1450, 1060) pyautogui.click(1450, 1060) keyboard.write("Hello! Welcome to the group for " + groupName) keyboard.press("enter") if 'hangouts.google.com' in web.get_current_url(): notWorked = False print(groupName + " was successfully created, hopefully.") totalGroups += 1 else: print(groupName + " NOT successfully created.") web.refresh() groupNum += 1 print("it got to here! end of the browser")
if answer == "twitter" or answer == "instagram" or answer == "spotify" or answer == "netflix": if answer == "twitter": username = input(str("Username (@????):")) url = "https://mobile.twitter.com/login?lang=en" elif answer == "netflix": username = input(str("E-mail or phone number:")) url = "https://www.netflix.com/login" elif answer == "instagram": username = input(str("Username:"******"https://www.instagram.com/accounts/login/?force_classic_login" elif answer == "spotify": username = input(str("E-mail or username:"******"https://accounts.spotify.com/login" web = Browser() web.go_to(url) urlcheck1 = web.get_current_url() urlcheck2 = web.get_current_url() checking = urlcheck2.endswith("%2F") passwordopen = open(pswd, "rt") i = 0 while urlcheck1 == urlcheck2 or checking == True: web.type(username, into="username") password = (select_line(i, pswd, passwordopen)).replace("\n", "") if password == "": break print(password) web.type(password, into="password") if answer == "instagram": time.sleep(1) web.press(web.Key.ENTER) time.sleep(1)
now = datetime.datetime.now() directory = now.strftime("%Y-%m-%d") if not os.path.exists(directory): os.makedirs(directory) web = Browser() web.go_to( "https://www.idealista.com/alquiler-habitacion/alcobendas-madrid/con-precio-hasta_500/" ) time.sleep(2) for habitaciones in range( 0, len(web.find_elements(tag='article', classname='item'))): web.find_elements(tag='article', classname='item')[habitaciones].click() time.sleep(1) x = web.get_current_url() filename = '{}/{}'.format(directory, x[35:-1]) if not os.path.exists(filename): os.makedirs(filename) filenameurl = '{}/{}.txt'.format(filename, 'url') f = open(filenameurl, "w+") f.write(web.get_current_url()) f.write("\r\n") filenameinfo = '{}/{}.txt'.format(filename, 'info') f = open(filenameinfo, "w+") f.write( web.find_elements(tag='section', classname='detail-info')[0].text) f.write("\r\n") time.sleep(1) print(len(web.find_elements(tag='div', classname='main-image_first'))) if len(web.find_elements(tag='div',
class TribalClient: def __init__(self, session_cookie, world, word_settings: WorldSettings = None): self.driver = Browser() self.world = world self._session_cookie = session_cookie self.barbarians = [] self.available_troops = {key.value: 0 for key in Troops} def login(self): self.driver.go_to('https://plemiona.pl') self.driver.add_cookie({ 'name': 'pl_auth', 'value': self._session_cookie }) self.driver.refresh() self.driver.click(text=str(self.world)) if self.driver.exists(id='popup_box_daily_bonus'): self.driver.click(classname='popup_box_close') def get_current_domain(self): uri = self.driver.get_current_url() parsed_uri = urlparse(uri) return f'{parsed_uri.scheme}://{parsed_uri.netloc}' def get_outgoings_attacks_from_place(self): self.go_to_place() outgoings_attacks_box = self.driver.driver.find_element_by_id( 'commands_outgoings') attacked_villages_elements = outgoings_attacks_box.find_elements_by_class_name( 'quickedit-label') @staticmethod def _replace_screen_in_url(url, screen_name: str) -> str: parsed_url = urlparse(url) parsed_query = parse_qs(parsed_url.query) parsed_query['screen'] = screen_name final_url = parsed_url._replace( query=urlencode(parsed_query, doseq=True)).geturl() return final_url def go_to_place(self): if 'screen=place' not in self.driver.get_current_url(): self.driver.go_to( f'{self.get_current_domain()}/game.php?village=62967&screen=place' ) def go_to_train_screen(self): if 'screen=train' not in self.driver.get_current_url(): self.driver.go_to( f'{self.get_current_domain()}/game.php?village=62967&screen=train' ) def go_to_main_screen(self): if 'screen=main' not in self.driver.get_current_url(): self.driver.go_to( self._replace_screen_in_url(self.driver.get_current_url(), 'main')) def slow_type(self, text, *args, **kwargs): text_input = self.driver.find_elements(*args, **kwargs)[0] text_input.clear() for letter in text: text_input.send_keys(letter) time.sleep(0.020) # self.driver.type(letter, *args, clear=False, **kwargs) def _extend_viallages_list(self): self.driver.driver.find_element_by_css_selector( '.village-item.village-more').click() def get_nearest_barbarians_villages(self, radius=10): # self.go_to_place() # self.driver.click(css_selector='input[value="village_name"]') # nazwa wioski radio button self.slow_type('Wioska Barbarzyńska', css_selector='#content_value .target-input-field') time.sleep(0.2) x = self.driver.driver.find_elements_by_class_name( 'target-input-field') farthest_village_distance = 1 villages = [] # time.sleep(0.5) while farthest_village_distance < radius: time.sleep(0.1) villages = self.driver.driver.find_elements_by_css_selector( 'div.target-select-autocomplete .village-item')[:-1] farthest_village_distance = parse_village_html( villages[-1]).distance self._extend_viallages_list() self.barbarians = [] for village in villages: parsed_village = parse_village_html(village) if parsed_village.owner == 'Barbarzyńskie': self.barbarians.append(parsed_village) def get_troop_type_count_from_place(self, troop_type): unparsed_number = self.driver.driver.find_element_by_id( f'units_entry_all_{troop_type}').text return int(unparsed_number[1:-1]) def get_troop_type_count_available_to_recruit(self, troop_type): self.go_to_train_screen() available_count_element = self.driver.driver.find_element_by_id( f'{troop_type.value}_0_a') return int(available_count_element.text[1:-1]) def get_available_troops(self): for troop_type in Troops: self.available_troops[ troop_type.value] = self.get_troop_type_count_from_place( troop_type) return self.available_troops def get_available_resources(self) -> Resources: wood = int(self.driver.driver.find_element_by_id('wood').text) stone = int(self.driver.driver.find_element_by_id('stone').text) iron = int(self.driver.driver.find_element_by_id('iron').text) max_storage = int( self.driver.driver.find_element_by_id('storage').text) population = int( self.driver.driver.find_element_by_css_selector( 'span#pop_current_label').text) max_population = int( self.driver.driver.find_element_by_css_selector( 'span#pop_max_label').text) return VillageResources(wood, stone, iron, population, timedelta(0), max_storage, max_population) def _fill_troop_form(self, troop_type, value): input_text = self.driver.driver.find_element_by_css_selector( f'#unit_input_{troop_type}') input_text.clear() input_text.send_keys(value) def fill_recruit_troop_form(self, troop_type, value): input_element = self.driver.driver.find_element_by_name( troop_type.value) input_element.clear() input_element.send_keys(str(value)) def confirm_recruit(self): confirm_btn = self.driver.driver.find_element_by_class_name( 'btn-recruit') confirm_btn.click() def _fill_target_village_cords(self, cords: Tuple[int, int]): target_input = self.driver.driver.find_element_by_class_name( 'target-input-field') target_input.send_keys(f'{cords[0]}{cords[1]}') time.sleep(uniform(0.1, 0.2)) def _confirm_attack(self): self.driver.driver.find_element_by_id('target_attack').click() time.sleep(uniform(0.1, 0.2)) self.driver.driver.find_element_by_id('troop_confirm_go').click() def send_attack(self, target_cords: Tuple[int, int], troop_config: dict): self.go_to_place() self._fill_target_village_cords(target_cords) for troop_type, troop_count in troop_config.items(): self._fill_troop_form(troop_type, troop_count) self._confirm_attack() def send_attack_to_nearest_villages(self, count=5, skip=0, light_chunk_count=5, axe_chunk_count=1): self.go_to_place() self.get_available_troops() count = light_chunk_count + axe_chunk_count light_chunk_size = int(self.available_troops[Troops.LIGHT.value] / light_chunk_count) axe_chunk_size = int(self.available_troops[Troops.AXE.value] / axe_chunk_count) for village in self.barbarians[skip:skip + count]: any_troops = False if light_chunk_count and light_chunk_size > 10: self._fill_troop_form(Troops.LIGHT, light_chunk_size) light_chunk_count -= 1 any_troops = True elif axe_chunk_count and axe_chunk_size > 50: self._fill_troop_form(Troops.AXE, axe_chunk_size) axe_chunk_count -= 1 any_troops = True if any_troops: self._fill_target_village_cords(village.cords) time.sleep(0.2) self._confirm_attack() time.sleep(0.2) def _get_build_row(self, building_name): return self.driver.driver.find_element_by_css_selector( f'tr#main_buildrow_{building_name}') def _get_build_orders_rows_for_building(self, building_name: str): return self.driver.driver.find_elements_by_class_name( f'buildorder_{building_name}') def _get_build_queue_rows(self): self.go_to_main_screen() return self.driver.driver.find_elements_by_css_selector( 'tbody#buildqueue>tr.nodrag, tbody#buildqueue>.sortable_row') def get_build_queue_size(self): return len(self._get_build_queue_rows()) def get_build_end_time(self): build_queue_rows = self._get_build_queue_rows() end_time = datetime.now() for build_row in build_queue_rows: time_string = build_row.find_element_by_css_selector('td') end_time += TimeHelper.parse_tribal_timedelta_format(time_string) return end_time def get_building_level(self, building_name) -> int: building_row = self._get_build_row(building_name) current_level_string = building_row.find_element_by_tag_name( 'td').find_element_by_tag_name('span').text try: current_level = int(re.search("\d+", current_level_string).group()) except AttributeError: current_level = 0 build_order_row_for_building = self._get_build_orders_rows_for_building( building_name) return current_level + len(build_order_row_for_building) def build(self, build_queue: deque): for i in range(2 - self.get_build_queue_size()): if not build_queue: print('Pusta kolejka') return building_name = build_queue.popleft() building_row = self._get_build_row(building_name) try: build_inactive_displayed = building_row.find_element_by_css_selector( 'span.inactive').is_displayed() except NoSuchElementException: build_inactive_displayed = False if build_inactive_displayed: print(f"Currently you can't build {building_name}") build_queue.appendleft(building_name) return build_button = building_row.find_element_by_css_selector( 'td.build_options a.btn-build') try: build_button.click() level = int(re.search(r'\d+', build_button.text).group()) print(f'Built {building_name} at level {level}') time.sleep(0.1) except StaleElementReferenceException: build_queue.appendleft(building_name) def continous_attack(self, light_chunk_size=20): self.go_to_place() self.get_available_troops() while True: if self.get_troop_type_count_from_place( Troops.LIGHT) >= light_chunk_size: village = random.choice(self.barbarians) self._fill_troop_form(Troops.LIGHT, light_chunk_size) time.sleep(0.2) self._fill_target_village_cords(village.cords) time.sleep(0.2) self._confirm_attack() else: time.sleep(0.2)
async def update_database(): my_file = 'classes.csv' # check if file exists if os.path.exists(my_file): os.remove(my_file) # Print the statement once the file is deleted print(f'An existing {my_file} has been found. The file: {my_file} will be deleted.') else: print(f'The file: {my_file} does not exist. Creating file now...') web = Browser() web.go_to('http://aisis.ateneo.edu/') web.click('click here') mirror = web.get_current_url().split('j_aisis') # enters credentials into the site ID_NUM = os.getenv('ID_NUM') PASSWORD = os.getenv('PASSWORD') web.type(ID_NUM, into='userName') web.type(PASSWORD, into='password') web.click('Sign in') # successfully signs into AISIS # web.click('CLASS SCHEDULE') web.go_to(f'{mirror[0]}j_aisis/J_VCSC.do') # html parsing page_soup = soup(web.get_page_source(), "html.parser") filename = 'subjects.csv' f = open(filename, 'w') headers = 'subject_code,section,course_title,units,time,room,instructor,max_no,lang,level,free_slots,remarks,s,p\n' f.write(headers) # grabs each product departments = page_soup.findAll( lambda t: t.name == 'option' and t.parent.attrs.get('name') == 'deptCode' ) subjects = [] subject_info = [] i = 1 for dept in departments: web.click('Display Class Schedule') page_soup = soup(web.get_page_source(), "html.parser") raw_data = page_soup.findAll('td', {'class':'text02'}) # gets the info in the subjects table j = 0 # column counter for data in raw_data: if j == 14: j = 0 subjects.append(subject_info) subject_info = [] f.write('\n') f.write(data.text.replace(',', '|') + ',') subject_info.append(data.text) j += 1 f.write('\n') if i < len(departments): web.click(departments[i].text) i += 1 f.close() databasefile = 'subjects.csv' # rearranges the csv file for more optimal searching db = pd.read_csv(databasefile, skip_blank_lines=True, names=['subject_code', 'section', 'course_title', 'units', 'time', 'room', 'instructor', 'max_no', 'lang', 'level', 'free_slots', 'remarks', 's', 'p']) # removes space in subject code db['subject_code'] = db['subject_code'].apply(remove_space) db.sort_values(by=['subject_code'], ascending=True).to_csv(databasefile, index=False)
from webbot import Browser from notify_run import Notify import pandas as pd from datetime import date def convert_MBtoGB(mb): return int(float(mb)/1024) web = Browser() web.go_to('??.in') web.type('', id='DUser') web.type('', id='Pwd') web.press(web.Key.ENTER) print(web.get_current_url()) web.go_to('??.in/goToForm?formId=CUP001') used_data_mb = web.find_elements(id='totalOctet')[0].text rem_data_mb = web.find_elements(id='totalOctets')[0].text today = date.today() print(used_data_mb) print(rem_data_mb) print(today) # # used_data_mb = '35100.55' # # rem_data_mb = '5000.45' used_data = convert_MBtoGB(used_data_mb) rem_data = convert_MBtoGB(rem_data_mb) web.go_to('??.in/signout')