def main(position, location): """Run the main program routine""" scraped_jobs = [] scraped_urls = set() url = get_url(position, location) # setup web driver options = EdgeOptions() options.use_chromium = True driver = Edge(options=options) driver.implicitly_wait(5) driver.get(url) # extract the job data while True: cards = driver.find_elements_by_class_name('jobsearch-SerpJobCard') get_page_records(cards, scraped_jobs, scraped_urls) try: driver.find_element_by_xpath('//a[@aria-label="Next"]').click() except NoSuchElementException: break except ElementNotInteractableException: driver.find_element_by_id('popover-x').click() # to handle job notification popup get_page_records(cards, scraped_jobs, scraped_urls) continue # shutdown driver and save file driver.quit() save_data_to_file(scraped_jobs)
options.use_chromium=True options.binary_location=r'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe' browser=Edge(options=options,executable_path=webdriver_location) running=False keybind=input("\n\n\n[!!] -Start typeing keybind, press on start of test: ") while True: try: if keyboard.is_pressed(keybind) == True and running == False: browser.get("https://www.typing.com/student/typing-test/1-minute") runningEFE=True newtype="" typestring=[] print('-Reading...') elements=browser.find_elements_by_class_name('screenBasic-letter') print("-Typing...") for e in elements: text=e.get_attribute("textContent") print(text) if "\xa0" in text: text=str(text).replace("\xa0"," ") if "\n" in text: text=str(text).replace("\n"," ") typestring.append(text) for c in typestring: newtype=str(newtype)+str(c) time.sleep(0.1) body=browser.find_element_by_xpath('/html/body') body.send_keys(str(newtype)) print(str(newtype))
options.use_chromium = True driver = Edge(options=options) driver.maximize_window() driver.get(url) # get current position of y scrollbar last_position = driver.execute_script("return window.pageYOffset;") reviews = [] review_ids = set() running = True while running: # get cards on the page cards = driver.find_elements_by_class_name('apphub_Card') for card in cards[-20:]: # only the tail end are new cards # gamer profile url profile_url = card.find_element_by_xpath('.//div[@class="apphub_friend_block"]/div/a[2]').get_attribute('href') # steam id steam_id = profile_url.split('/')[-2] # check to see if I've already collected this review if steam_id in review_ids: continue else: review_ids.add(steam_id)
driver.get(url_names) txt_box = driver.find_element_by_xpath('//*[@id="main"]/div/form/input[3]') txt_box.clear() txt_box.send_keys("95") # men select = Select(driver.find_element_by_xpath('//*[@id="gender"]')) select.select_by_visible_text('male') time.sleep(2) driver.find_element_by_xpath('//*[@id="qc-cmp2-ui"]/div[2]/div/button[2]').click() time.sleep(3) driver.execute_script("window.scrollTo(0, 1080)") driver.find_element_by_xpath('//*[@id="main"]/div/form/input[4]').click() time.sleep(5) names = driver.find_elements_by_class_name('name_heading') for name in names: names_men.append(name.text) # women select = Select(driver.find_element_by_xpath('//*[@id="gender"]')) select.select_by_visible_text('female') time.sleep(2) actions = ActionChains(driver) element = driver.find_element_by_xpath('//*[@id="main"]/div/form/input[4]') actions.move_to_element(element).click().perform() time.sleep(5) names = driver.find_elements_by_class_name('name_heading') for name in names: names_women.append(name.text)