def get_key_request_param(self, ori_url): try: chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-gpu') prefs = {'profile.managed_default_content_settings.images': 2} chrome_options.add_experimental_option('prefs', prefs) browser = webdriver.Chrome(chrome_options=chrome_options) # browser = webdriver.Firefox() cookie = self.headers["cookie"] simple_cookie = SimpleCookie(cookie) browser.get(ori_url) format_cookie = {} for item in simple_cookie: format_cookie['name'] = item format_cookie['value'] = simple_cookie[item].value browser.add_cookie(cookie_dict=format_cookie) browser.get(ori_url) soup = BeautifulSoup(browser.page_source, "html.parser") titles = soup.select("body script") stri = titles[-2].get_text() browser.close() regex = re.compile(r"videoId: '.*'") video_id = regex.findall(stri)[0][10:-1] regex = re.compile(r"videoPlaySafe: '.*'") video_play_safe = regex.findall(stri)[0][16:-1] return video_id, video_play_safe except: traceback.print_exc()
def get_driver(): with open('config.yaml', 'r') as f: try: config = load(f) if config['config']['driver'] == "firefox": options = Options() options.add_argument("--headless") options.add_argument("--disable-notifications") ffprofile = webdriver.FirefoxProfile() ffprofile.set_preference("dom.webnotifications.enabled", False) driver = webdriver.Firefox( firefox_profile=ffprofile, firefox_options=options, executable_path='/usr/local/bin/geckodriver') elif config['config']['driver'] == "chrome": options = ChromeOptions() options.add_argument("--headless") options.add_argument("--disable-notifications") prefs = { "profile.default_content_setting_values.notifications": 2 } options.add_experimental_option("prefs", prefs) driver = webdriver.Chrome( chrome_options=options, executable_path='/usr/local/bin/chromedriver') else: print(f"{b64(config['config']['driver'])} is not supported") exit() return driver except YAMLError as e: print(e)
def init_driver(headless=True, proxy=None, show_images=False, option=None, firefox=False, env=None): """ initiate a chromedriver or firefoxdriver instance --option : other option to add (str) """ if firefox: options = FirefoxOptions() driver_path = geckodriver_autoinstaller.install() else: options = ChromeOptions() driver_path = chromedriver_autoinstaller.install() if headless is True: print("Scraping on headless mode.") options.add_argument('--disable-gpu') options.headless = True else: options.headless = False options.add_argument('log-level=3') if proxy is not None: options.add_argument('--proxy-server=%s' % proxy) print("using proxy : ", proxy) if show_images == False and firefox == False: prefs = {"profile.managed_default_content_settings.images": 2} options.add_experimental_option("prefs", prefs) if option is not None: options.add_argument(option) if firefox: driver = webdriver.Firefox(options=options, executable_path=driver_path) else: driver = webdriver.Chrome(options=options, executable_path=driver_path) driver.set_page_load_timeout(100) return driver
def get_options_chrome(self, download_dir): from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options(); prefs = {"download.default_directory": download_dir,"download.directory_upgrade": True,"download.prompt_for_download": False,"safebrowsing.enabled": False,"safebrowsing.disable_download_protection": True,"page.setDownloadBehavior": {'behavior': 'allow', 'downloadPath': download_dir}} options.add_experimental_option("prefs",prefs); options.add_argument("--test-type"); options.add_argument("--no-sandbox"); options.add_argument("--incognito"); options.add_argument("--disable-extensions"); #options.add_argument("--start-maximized"); return options;
def set_options(headless: bool, driver_to_use: str) -> Options: ''' Many content types are set to not show download dialogs to prevent headaches, but the main ones are the following: CBI: application/unknown 896: application/x-download ''' if driver_to_use == "Firefox": options = Options() options.set_preference("browser.download.folderList", 2) options.set_preference("browser.download.dir", DOWNLOAD_PATH) options.set_preference("browser.download.forbid_open_with", True) options.set_preference("browser.download.manager.alertOnEXEOpen", False) options.set_preference( "browser.helperApps.neverAsk.openFile", "application/unknown, application/x-www-form-urlencoded, application/msword, application/csv, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/x-download, application/octet-stream" ) options.set_preference( "browser.helperApps.neverAsk.saveToDisk", "application/unknown, application/x-www-form-urlencoded, application/msword, application/csv, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/x-download, application/octet-stream" ) options.set_preference("browser.download.manager.showWhenStarting", False) options.set_preference("browser.download.manager.focusWhenStarting", False) options.set_preference("browser.download.useDownloadDir", True) options.set_preference("browser.helperApps.alwaysAsk.force", False) options.set_preference("browser.download.manager.alertOnEXEOpen", False) options.set_preference("browser.download.manager.closeWhenDone", True) options.set_preference("browser.download.manager.showAlertOnComplete", False) options.set_preference("browser.download.manager.useWindow", False) options.set_preference( "services.sync.prefs.sync.browser.download.manager.showWhenStarting", False) options.set_preference("pdfjs.disabled", True) options.set_headless(headless) return options if driver_to_use == "Chrome": options = webdriver.ChromeOptions() prefs = { "profile.default_content_settings.popups": 0, "download.default_directory": DOWNLOAD_PATH + "\\", # IMPORTANT - ENDING SLASH V IMPORTANT "directory_upgrade": True } options.headless = headless options.add_argument("--log-level=3") options.add_experimental_option("prefs", prefs) return options
def spider_opened(self, spider): spider.logger.info('Spider opened: %s' % spider.name) options = Options() # options.add_argument('--headless') options.add_argument('--disable-gpu') # options.add_argument('--disable-infobars') options.add_experimental_option('excludeSwitches', ['enable-automation']) # path = r'E:\chromedriver.exe' self.driver = Firefox(firefox_binary='D:\\fire fox\\firefox.exe', executable_path='D:\geckodriver.exe') self.driver.maximize_window()
def get_options(self): if self.get_type() == 'firefox': options = FirefoxOptions() if self.get_args(): for arg in self.get_args().split(): options.add_argument('--' + arg) if self.bin_path: options.binary_location(self.bin_path) if self.get_headless(): options.headless = True if self.get_window_size(): win_size = self.get_window_size().split(',') options.add_argument('--width=' + win_size[0]) options.add_argument('--height=' + win_size[1]) # Set download path options.set_preference('browser.download.folderList', 2) options.set_preference('browser.download.dir', get_download_path()) options.set_preference('browser.download.manager.showWhenStarting', False) options.set_preference('browser.helperApps.alwaysAsk.force', False) options.set_preference('browser.helperApps.neverAsk.saveToDisk', "application/octet-stream") # options.set_preference('browser.helperApps.neverAsk.openFile', "application/octet-stream") elif self.get_type() == 'ie': options = IeOptions() options.ignore_protected_mode_settings = False options.require_window_focus = True options.native_events = False # proceed IE options here else: options = ChromeOptions() if self.get_args(): for arg in self.get_args().split(): options.add_argument(arg) if self.bin_path: options.binary_location(self.bin_path) if self.get_headless(): options.headless = True if self.get_window_size(): options.add_argument('--window-size=' + self.get_window_size()) # Set download path prefs = {} prefs["download.prompt_for_download"] = 0 prefs["download.default_directory"] = get_download_path() options.add_experimental_option("prefs", prefs) return options
def sel_options(headless: bool = True, firefox: bool = False): if firefox: op = FireOpt() else: op = ChroOpt() op.add_experimental_option( "prefs", { "download.prompt_for_download": False, "download.directory_upgrade": True, "safebrowsing.enabled": True, }, ) op.add_argument("--disable-notifications") if headless: op.add_argument("--headless") return op
def launch_browser(cls): app.logger.warning(f'Launching {util.get_xena_browser().capitalize()}') if util.get_xena_browser() == 'firefox': p = FirefoxProfile() p.set_preference(key='devtools.jsonview.enabled', value=False) options = Foptions() options.profile = p return webdriver.Firefox(options=options) else: d = DesiredCapabilities.CHROME d['loggingPrefs'] = {'browser': 'ALL'} options = Coptions() prefs = { 'profile.default_content_settings.popups': 0, 'download.default_directory': util.default_download_dir(), 'directory_upgrade': True, } options.add_experimental_option('prefs', prefs) return webdriver.Chrome(desired_capabilities=d, options=options)
def _load_driver(download_dir=None): """ Load the Selenium driver :return: driver """ browserName = BROWSER browser_data_path = getBrowserDataPath(browser=browserName) web_driver_path = getDriverPath(driver=browserName) driver = None if browserName.lower() == "firefox": option = OptionFirefox() if browser_data_path is not None: option.add_argument('user-data-dir=' + browser_data_path) if download_dir is not None: if os.path.exists(download_dir): p = {'download.default_directory': download_dir} #todo: add download folder here pass else: logger.debug(f"Using default download path {download_dir} doesn't exist") try: driver = webdriver.Firefox(executable_path=web_driver_path, options=option) except InvalidArgumentException: print(f"Another Window of {browserName.title()} is open Close it and try again:Ъце") sys.exit() elif browserName.lower() == "chrome": option = OptionsChrome() option.add_argument('user-data-dir=' + browser_data_path) if download_dir is not None: if os.path.exists(download_dir): p = {'download.default_directory': download_dir} option.add_experimental_option('prefs', p) else: logger.debug(f"Using default download path {download_dir} doesn't exist") try: driver = webdriver.Chrome(executable_path=web_driver_path, options=option) except InvalidArgumentException: print(f"Another Window of {browserName.title()} is open Close it and try again:Ъце") sys.exit() return driver
def browser(request): browser_name = request.config.getoption("browser_name") user_language = request.config.getoption("language") if browser_name == "firefox": fp = webdriver.FirefoxProfile() fp.set_preference("intl.accept_languages", user_language) options = FirefoxOptions() options.add_argument("-headless") browser = webdriver.Firefox(firefox_profile=fp, options=options) print("\n starting firefox browser for test..") else: options = ChromeOptions() options.add_experimental_option('prefs', {'intl.accept_languages': user_language }) options.add_experimental_option('excludeSwitches', ['enable-logging']) browser = webdriver.Chrome(options=options) print("\n starting chorme browser for test..") yield browser print("\n quit browser..") time.sleep(5) browser.quit()
def open_browser(browserName,*args): global driver,waitUtil try: if browserName.lower() == 'ie': driver= webdriver.Ie(executable_path = ieDriverFilePath) elif browserName.lower() == 'chrome': chrome_options= Options() #添加屏蔽 --ignore-certificate-errors 提示信息的设置参数项 chrome_options.add_experimental_option( "excludeSwitches", ["ignore-certificate-errors"] ) driver = webdriver.Chrome(executable_path=chromeDriverFilePath, chrome_options=chrome_options) else: driver=webdriver.Firefox(executable_path=firefoxDriverFilePath) waitUtil = WaitUtil(driver) except Exception,e: raise e
def __init__(self, headless=True, window_size='1920,1080', additional_options=(), timeout=3, browser_type='chrome'): if browser_type == 'firefox': options = FirefoxOptions() options.headless = headless self.driver = webdriver.Firefox(options=options) if window_size: self.driver.set_window_size( *[int(token) for token in window_size.split(',')]) else: options = ChromeOptions() options.headless = headless if window_size: options.add_argument(f'--window-size={window_size}') for o in additional_options: options.add_argument(o) options.add_argument('--ignore-certificate-errors') options.add_argument('disable-infobars') options.add_argument('--disable-notifications') options.add_argument('--no-sandbox') options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_experimental_option('useAutomationExtension', False) options.add_experimental_option("prefs", {"enable_do_not_track": True}) self.driver = webdriver.Chrome(options=options) self.timeout = timeout self.driver.implicitly_wait(self.timeout)
def select_chrome(download_path, headless, full_screen, height, width, browser_drivers_path): """ Method to choose given options for Chrome browser :param download_path: path where downloaded files will be saved :type headless: bool :type full_screen: bool :type height: int :type width: int :param browser_drivers_path: path to browser executable file. """ from selenium.webdriver.chrome.options import Options chrome_options = Options() preferences = {'download.default_directory': download_path} chrome_options.add_experimental_option('prefs', preferences) if headless: chrome_options.add_argument("--headless") if full_screen: chrome_options.add_argument("--start-maximized") else: chrome_options.add_argument("--window-size={},{}".format( height, width)) return webdriver.Chrome(options=chrome_options, executable_path=browser_drivers_path['chrome'])
def browser(boolean): options = Options() # driver = webdriver.PhantomJS() # driver = Firefox(executable_path='geckodriver', firefox_options=options) if boolean == True: print('-------------------->无头模式<--------------------') options.add_argument('--disable-gpu') options.add_argument('--headless') options.binary_location = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' driver = webdriver.Chrome(options=options) return driver else: print('-------------------->有头模式<--------------------') # 自动下载目录,禁止下载弹窗 prefs = { 'profile.default_content_settings.popups': 0, 'download.default_directory': 'F:\\WorkPlace\\Python\\python\\AutoBaikeProject\\website\\test_data\imgs' } options.add_experimental_option('prefs', prefs) options.binary_location = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' driver = webdriver.Chrome(options=options) return driver
def setUp(self, browser=settings.DEFAULT_TEST_BROWSER, browser_locale="en"): self._download_dir = TemporaryDirectory() if browser == "firefox": profile = webdriver.FirefoxProfile() # Set browser language for web pages profile.set_preference("intl.accept_languages", browser_locale) # Set default browser download dir and remove download prompt profile.set_preference("browser.download.dir", self._download_dir.name) profile.set_preference("browser.download.folderList", 2) profile.set_preference("browser.download.manager.showWhenStarting", False) mime_type_list = "application/octet-stream" profile.set_preference("browser.helperApps.neverAsk.openFile", mime_type_list) profile.set_preference("browser.helperApps.neverAsk.saveToDisk", mime_type_list) options = FirefoxOptions() if settings.TEST_BROWSER_HEADLESS: options.headless = True if settings.BROWSER_BINARY_PATH: options.binary_location = settings.BROWSER_BINARY_PATH self.browser = webdriver.Firefox( executable_path=settings.DEFAULT_GECKODRIVER_PATH, firefox_profile=profile, firefox_options=options, ) elif browser == "chrome": options = ChromeOptions() # --lang argument is no more supported on Linux # see: https://bugs.chromium.org/p/chromium/issues/detail?id=755338#c14 if platform.system() == "Linux": os.environ["LANGUAGE"] = browser_locale else: options.add_argument(f"--lang={browser_locale}") # Set default browser download dir and remove download prompt chrome_profile = { "download.default_directory": self._download_dir.name, "savefile.default_directory": self._download_dir.name, "download.prompt_for_download": False, "download.directory_upgrade": True, "profile.default_content_setting_values.automatic_downloads": 1, } if settings.TEST_BROWSER_HEADLESS: options.add_argument("--headless") options.add_argument("--no-sandbox") options.add_argument("--disable-dev-shm-usage") if platform.system() == "Windows": # Needed due to Chrome bug options.add_argument("--disable-gpu") if settings.BROWSER_BINARY_PATH: options.binary_location = settings.BROWSER_BINARY_PATH options.add_experimental_option("prefs", chrome_profile) self.browser = webdriver.Chrome( executable_path=settings.DEFAULT_CHROMEDRIVER_PATH, chrome_options=options, ) else: raise ValueError("Unsupported browser, allowed: firefox, chrome") # Set a default window size self.browser.set_window_size(1366, 768) # Set default timeout self.browser.implicitly_wait(1)
class PlacementScraper(): def __init__(self,debug=False): self.scraperUI = ScraperUI() self.browser = self.scraperUI.GetBrowserPreference() self.google_group = self.scraperUI.GetGoogleGroup() if self.google_group: if self.browser == 'Firefox': self.SetupFirefoxDriver() elif self.browser == 'Chrome': self.SetupChromeDriver() self.first_page = True self.headers_row = ['Name of the Company', 'Category', 'Date of Visit: ', 'CTC', 'Stipend'] self.all_registration_links = [] self.filename = 'placementInfo' + self.google_group + '.xlsx' self.GetYearFromGoogleGroup() self.CreateRegistrationSearchText() self.CreateOutputFile() if debug: self.test() else: self.next_page_element_class = 'uArJ5e Y5FYJe cjq2Db YLAhbd M9Bg4d' self.OpenVitiansGroupLink() while not self.CheckNextButtonDisabled() or self.first_page: if self.first_page: self.first_page = False self.GetAllRegistrationLinks() self.GetNextPage() self.DestroyDriver() def CreateRegistrationSearchText(self): self.registration_search_texts = ['placement Registration ' + str(self.year) + ' Batch', 'Registration Notice -'] def CheckNextButtonDisabled(self): try: self.next_page_element = self.driver.find_element_by_css_selector('div[aria-label="Next page"]') self.next_page_exists = self.next_page_element.get_attribute('aria-disabled') if self.next_page_exists == 'false': return False else: return True except NoSuchElementException: return True def CreateOutputFile(self): if not os.path.exists(self.filename): output_workbook = Workbook() output_worksheet = output_workbook.active output_worksheet.append(self.headers_row) output_workbook.save(self.filename) def OpenVitiansGroupLink(self): self.link = 'https://groups.google.com/g/' + self.google_group self.driver.get(self.link) def GetNextPage(self): self.next_page_element = self.driver.find_element_by_css_selector('div[aria-label="Next page"]') self.next_page_element.click() element = WebDriverWait(self.driver, 10).until( EC.presence_of_element_located((By.CSS_SELECTOR, 'div[class="NUZAVc L6cTce"]'))) def GetYearFromGoogleGroup(self): self.year = '' for digit in self.google_group: if digit.isdigit(): self.year += str(digit) if len(self.year) == 5: self.year = self.year[1:] def GetAllRegistrationLinks(self): self.all_registration_elements = self.driver.find_elements_by_css_selector( 'span[class=" eois5 ETPPOd USV3fe CzRzXb dwBwye"') for webpage in self.all_registration_elements: for self.registration_search_text in self.registration_search_texts: try: if self.registration_search_text in webpage.text: webpage.click() overlay_element = self.driver.find_element_by_css_selector( 'c-wiz[class="zQTmif SSPGKf eejsDc oCHqfe"]') style_attr = overlay_element.get_attribute('style') while 'visibility: hidden; opacity: 0;' in str(style_attr): overlay_element = self.driver.find_element_by_css_selector( 'c-wiz[class="zQTmif SSPGKf eejsDc oCHqfe"]') style_attr = overlay_element.get_attribute('style') time.sleep(2) self.GetTableContents() self.WriteRecord() self.PrintRecord() self.driver.back() except: pass def GetTableContents(self): try: self.main_body = self.driver.find_element_by_class_name('ptW7te') self.table_element = self.main_body.find_element_by_tag_name('table') except NoSuchElementException: self.main_body = self.driver.find_element_by_class_name('gmail_quote') self.table_element = self.main_body.find_element_by_tag_name('table') self.table_rows = self.table_element.find_elements_by_tag_name('tr') self.row_information = ['', '', '', '', ''] for row in self.table_rows: for header_num in range(len(self.headers_row)): if self.headers_row[header_num] in str(row.text): self.row_information[header_num] = str(row.text).replace(self.headers_row[header_num], '').strip() break if self.row_information[3] == '': for row in self.table_rows: if '13.9' in str(row.get_attribute('style')) : self.row_information[3] += str(row.text) self.row_information[3] = self.row_information[3].replace('CTC', '').strip() def test(self): self.test_link = 'https://groups.google.com/g/vitians02021/c/aA_-lxRig8s/m/ir5RruNdAQAJ' self.driver.get(self.test_link) self.GetTableContents() self.WriteRecord() self.PrintRecord() self.driver.back() def SetupChromeDriver(self): self.options = Options() self.options.add_argument('--no-sandbox') self.options.add_experimental_option('excludeSwitches', ['enable-logging']) self.chrome_driver_path = r"chromedriver.exe" self.driver = webdriver.Chrome(executable_path=self.chrome_driver_path, options=self.options) def SetupFirefoxDriver(self): self.options = FirefoxOptions() self.options.add_argument('--no-sandbox') self.firefox_driver_path = r"geckodriver.exe" self.driver = webdriver.Firefox(executable_path=self.firefox_driver_path, options=self.options) def DestroyDriver(self): try: self.driver.quit() self.driver.close() except: pass def WriteRecord(self): if os.path.exists(self.filename): output_workbook = load_workbook(self.filename) output_worksheet = output_workbook.worksheets[0] output_worksheet.append(self.row_information) output_workbook.save(self.filename) def PrintRecord(self): for num in range(len(self.headers_row)): print(self.headers_row[num], self.row_information[num], sep=" : ", end=' , ') print()
from selenium.webdriver.firefox.options import Options load_dotenv() # for firefox options = Options() options.set_preference('dom.webnotifications.enabled', False) options.set_preference("geo.prompt.testing", True) options.set_preference("geo.prompt.testing.allow", True) # comment or uncomment if want to use # driver = webdriver.Firefox(options=options, executable_path="driver/firefox/Darwin/geckodriver") # for chrome options = webdriver.ChromeOptions() prefs = {"profile.default_content_setting_values.notifications": 2} options.add_experimental_option("prefs", prefs) # comment or uncomment if want to use driver = webdriver.Chrome(options=options, executable_path="driver/chrome/Darwin/chromedriver") buttonAccept = '//span[@class="Pos(r) Z(1)" and contains(text(), "I Accept")]' buttonGoogle = '//button[@class="button Lts($ls-s) Z(0) CenterAlign Mx(a) Pos(r) Cur(p) Tt(u) Bdrs(100px) Px(48px) Px(40px)--s Py(0) Mih(54px) button--outline Bdw(2px) Bds(s) Trsdu($fast) Bdc($c-secondary) C($c-secondary) Bdc($c-base):h C($c-base):h Bdc($c-base):f C($c-base):f Bdc($c-base):a C($c-base):a Fw($semibold) focus-button-style Mb(20px)--ml W(100%)--ml W(100%)--s Fz(4vw)--s"]' identifierIdField = 'identifierId' passwordField = 'password' buttonAllowNotif = '//span[contains(text(), "Allow")]' buttonEnableNotif = '//span[contains(text(), "Enable")]' keepSwiping = '//span[@class="StretchedBox Pe(n) noBg+D(n) Z(-1) Bgc(#000.8) Bdf($overlay-blur)"]' buttonLike = '//button[@type="button" and @aria-label="Like"]' driver.delete_all_cookies() browser = driver.desired_capabilities['browserName']
def get_browser_instance(self): try: if self.browser.lower() == "firefox": options = FirefoxOptions() if self.headless: options.add_argument("--headless") #options.add_argument("--disable-gpu") profile = webdriver.FirefoxProfile() #options.add_argument("--private") # options.add_argument("-width=1920") # options.add_argument("-height=1080") profile.accept_untrusted_certs = True driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(), firefox_profile=profile, options=options) elif self.browser.lower() == "chrome": chrome_options = Options() if self.headless: chrome_options.add_argument('headless') #chrome_options.add_argument('window-size=1920x1080') chrome_options.add_argument('ignore-certificate-errors') chrome_options.add_argument('--incognito') chrome_options.add_argument('--start-maximized') # chrome_options.add_experimental_option('prefs', {'geolocation': True}) chrome_options.add_experimental_option('useAutomationExtension', False) chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"]) chrome_options.add_argument('--log-level=3') # driver = webdriver.Chrome(options=chrome_options, executable_path='drivers//chromedriver.exe') driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options) elif self.browser.lower() == "ie": driver = webdriver.Ie(IEDriverManager().install()) elif self.browser.lower() == "edge": options = EdgeOptions() if self.headless: options.add_argument('headless') options.use_chromium = True #options.add_argument('window-size=1920x1080') options.add_argument('ignore-certificate-errors') options.add_experimental_option('useAutomationExtension', False) options.add_argument('--inprivate') options.add_argument('--log-level=3') options.add_experimental_option("excludeSwitches", ["enable-automation"]) driver = webdriver.Chrome(EdgeChromiumDriverManager().install(), options=options) elif self.browser.lower() == 'browserstack': # bs_local = Local() # bs_local_args = {"key": key,"localIdentifier": localIdentifier} # bs_local.start(**bs_local_args) driver = webdriver.Remote(command_executor=bb_url, desired_capabilities=browser_config) else: raise ValueError if self.headless: self.cl.info("Starting " + str(self.browser).upper() + " browser in headless mode") else: self.cl.info("Starting " + str(self.browser).upper() + " browser ") driver.maximize_window() # if self.baseUrl: # driver.get(self.baseUrl) # self.cl.info("Opening the URL :: " + str(self.baseUrl)) driver.implicitly_wait(5) driver.delete_all_cookies() driver.set_page_load_timeout(20) return driver except ValueError as e: self.cl.error("Browser not supported :: " + str( self.browser) + ". Supported browser types are Chrome, Firefox, Edge. Exception occurred. :: " + str( e.__class__.__name__) + ' ' + str(e)) raise e except Exception as e: self.cl.error("Exception occurred. :: " + str( e.__class__.__name__) + ' ' + str(e)) raise e
def grab(): browser = request.user_agent.browser topic = request.form.get("topic") txt_pdf = request.form.get("format") if browser == "Firefox": options = Options() options.headless = True driver = webdriver.Firefox(options=options) else: options = webdriver.ChromeOptions() options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"]) options.add_argument('--disable-gpu') options.add_argument('--headless') options.add_argument('--incognito') driver = webdriver.Chrome(chrome_options=options) driver.get("https://medium.com/") driver.implicitly_wait(10) #action = webdriver.ActionChains(driver) time.sleep(2) login = driver.find_element_by_link_text('Sign in').click() try: login_google = driver.find_element_by_xpath('/html/body/div[4]/div/div/section/div[1]/div/button[1]').click() except TimeoutException: pass # You can log-in using google only__name__ print(" Logging in to Medium by using Google ") time.sleep(3) #assert "Sign in – Google accounts" in driver.title user = driver.find_element_by_xpath('//*[@id="identifierId"]') # fetch your email or phone number as registered in Medium user.send_keys(username) # Provide your email or registered phone number here nextButton = driver.find_element_by_xpath('//*[@id="identifierNext"]/content') nextButton.click() time.sleep(2) user = driver.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input') # fetch your password to login user.send_keys(password) LOG = driver.find_element_by_xpath('//*[@id="passwordNext"]/content').click() print('LOGIN SUCCESSFUL \n') if topic == "Home": t = driver.get("https://medium.com/") else: t = driver.get("https://medium.com/topic/"+topic) print('The list of articles under this topic are saved in output file : ') # print('Just scan through the file and open the link whichever you want to read :) \n') print('The program is crawling down the webpage to gather links of around past 50 atricles. This may take around a minute or two.') # To Scroll to the bottom/ a portion of page last_height = 1000 while True: driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(2) new_height = driver.execute_script("return document.body.scrollHeight") if new_height >= last_height: break tag = driver.find_elements_by_tag_name('h3') tag_len = len(tag) links = [i.get_attribute('href') for i in driver.find_elements_by_xpath("//a[@data-action-source]")] unique_list = list(OrderedDict(zip(links, repeat(None)))) # To remove duplicates from list if txt_pdf == "PDF": title = 'Medium Grabber' pdf = FPDF() pdf.alias_nb_pages() pdf.add_page() pdf.set_title(title) pdf.set_font('Times', 'B', 24) pdf.cell(0, 10, 'Medium Grabber Links: ', 0, 1) pdf.set_font('Times', '', 12) if topic == "Home": # Different structure of Home and other topic pages. if tag_len > 0: for i,l in zip(range(tag_len), unique_list): pdf.set_text_color(r=0, g=0, b=0) pdf.cell(0, 6, str(time.strftime("%Y-%m-%d %H:%M")), 0, 1) # Writing the Article text text = tag[i].text.encode('latin-1', 'ignore') # Eliminates any non-ASCII charachters text = text.decode('latin-1') # Again decodes the string into byte-form pdf.cell(0, 6, text , 0, 1) pdf.set_text_color(r=0, g=0, b=250) # Writing the Article link pdf.multi_cell(0, 6, str(l), 0) pdf.cell(0, 6, ' ', 0, 1) else: for i in range(tag_len): pdf.set_text_color(r=0, g=0, b=0) pdf.cell(0, 6, time.strftime("%Y-%m-%d %H:%M"), 0, 1) text = tag[i].text.encode('latin-1', 'ignore') text = text.decode('latin-1') pdf.cell(0, 6,text, 0, 1) l = tag[i].find_element_by_css_selector('a').get_attribute('href') pdf.set_text_color(r=0, g=0, b=250) pdf.multi_cell(0, 6, str(l), 0) pdf.cell(0, 6, ' ', 0, 1) pdf.output('static/output.pdf', 'F') print('FINISHED! Please check the output.pdf file for the links. Happy reading. :) ') else: f= open("static/output.txt","w+", encoding='utf-8') # Stores ouput in output.txt in the same file directory if topic == "Home": # Different structure of Home and other topic pages. if tag_len > 0: for i,l in zip(range(tag_len), unique_list): f.write(time.strftime("%Y-%m-%d %H:%M") + '\n') f.write(tag[i].text) f.write('\nLink is --> ' + str(l) + '\n\n') else: for i in range(tag_len): f.write(time.strftime("%Y-%m-%d %H:%M") + '\n') f.write(tag[i].text) l = tag[i].find_element_by_css_selector('a').get_attribute('href') f.write('\nLink is --> ' + str(l) + '\n\n') f.close() print('FINISHED! Please check the output.txt file for the links. Happy reading. :) ') driver.close() duration = 2500 # millisecond freq = 440 # Hz if platform.system()=='Windows': winsound.Beep(freq, duration) return txt_pdf
from pyvirtualdisplay import Display import pyautogui from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument("--disable-extensions") #chrome_options.add_experimental_option("profile.default_content_settings.popups", 0) # chrome_options.add_experimental_option("download.prompt_for_download", "false") # chrome_options.add_experimental_option("download.default_directory", "/tmp") chrome_options.add_experimental_option( "prefs", { "download.default_directory": r"/home/araketu/Documentos/dev/random", "download.prompt_for_download": False, "download.directory_upgrade": True, "safebrowsing.enabled": True }) driver = webdriver.Chrome(chrome_options=chrome_options, executable_path='//usr/bin/chromedriver') print('\nEntrando no site TST...') driver.get('http://www.tst.jus.br/certidao') print('\nTrocando de frame') driver.switch_to_frame(driver.find_element_by_xpath('//iframe')) print('\nProcurando o botão de emissão e clicando') emiti = driver.find_element_by_xpath(
print(f'HEADLESS:{HEADLESS}') #print(sys.argv) print('setting up!') browser = sys.argv[1].lower() if browser == "firefox": from selenium.webdriver.firefox.options import Options options = Options() options.headless = HEADLESS ff = Firefox(executable_path=FF_PATH, options=options) elif browser == "chrome": from selenium.webdriver.chrome.options import Options options = Options() if sys.argv[-1].lower() == 'android': options.add_experimental_option('androidPackage', 'com.android.chrome') print('run on android') ff = Chrome(CHRA_PATH, options=options) else: options.headless = HEADLESS ff = Chrome(executable_path=CHR_PATH, options=options) elif browser == "debug": print("Debug mode") print('run script in interactive mode with -i option') debug = True else: print(f"unsupported {browser} browser") exit(1) if not debug: print(' *Loading window...') ff.get(URL)
def _Get_Attenndence_Selenium(self): display = Display(visible=0, size=(800, 600)) display.start() options = Options() options.add_experimental_option("prefs", { "download.default_directory": r"/home/odoo/Downloads", "download.prompt_for_download": False, "download.directory_upgrade": True, "safebrowsing.enabled": True }) browser = webdriver.Chrome(executable_path="/home/odoo/Downloads/chromedriver") browser.wait = WebDriverWait(browser, 5) browser.get('http://37.99.147.178:4370') xpaths = { 'username' : "//input[@name='username']", 'passwd' : "//input[@name='userpwd']", 'login' : "//input[contains(@value,'Login')]", 'download' : "//input[contains(@value,'Download')]", 'search' : "//input[contains(@value,'Search')]", 'report' : "//a[text()='Report']" } print "Browser is opened" browser.find_element_by_xpath(xpaths['username']).clear() browser.find_element_by_xpath(xpaths['username']).send_keys('10403') time.sleep(3) print "username is typed" browser.find_element_by_xpath(xpaths['passwd']).clear() browser.find_element_by_xpath(xpaths['passwd']).send_keys('10403') time.sleep(3) print "password is typed" browser.find_element_by_xpath(xpaths['login']).click() browser.get('http://37.99.147.178:4370/csl/download') time.sleep(3) browser.find_element_by_xpath(xpaths['download']).click() # time.sleep(50) # browser.quit() print "browser Closed" time.sleep(3) dir_path = os.path.dirname(os.path.realpath(__file__)) DIR_PATH = '/home/odoo/Downloads'+'/attlog.dat' # DIR_PATH = '/home/odoo/' list_id=[] list_name=[] list_date=[] list_time=[] for line in open(DIR_PATH, 'r'): item = line.rstrip() words=item.replace('\t', ' ') w_list = words.split(" ") count_name=0 count_id=0 count_id_id =0 count_date=0 count =0 for record in w_list: count = count + 1 if count == 1: list_id.append(record) if count == 2: list_name.append(record) if count == 3: list_date.append(record) if count == 4: list_time.append(record) index_id=0 for emp_id in list_id: print list_id[index_id] print list_date[index_id] print "search preveious Record " raw_attendence=self.env['ecube.raw.attendance'].search([('machine_id','=',list_id[index_id]),('machine_date','=',list_date[index_id]),('machine_time','=',list_time[index_id])]) print "recored match" if not raw_attendence: employee_id_raw =self.env['hr.employee'].search([('emp_machin_id','=',list_id[index_id])]) print employee_id_raw print "create record" self.env['ecube.raw.attendance'].create({ 'employee_name': employee_id_raw.id, 'machine_id': list_id[index_id], 'machine_date': list_date[index_id], 'machine_time': list_time[index_id], }) index_id = index_id +1 if "%s/attlog.dat" % DIR_PATH: os.remove(DIR_PATH) # display.stop() # /home/odoo/phantomjs/home/odoo/phantomjs # Steps that required for this F*****G machine # Install https://github.com/dnaextrim/python_zklib this library # Install Selenium # Download Gekodriver # Export path of Geckodriver # Install sudo apt-get install xvfb #install sudo pip install pyvirtualdisplay
def __get_web_driver__(self): #self.logger.info(self.BROWSER) self.logger.info("Using Browser: %s", self.BROWSER) if "Firefox" in self.BROWSER: profile = webdriver.FirefoxProfile() # enable auto download # http://stackoverflow.com/questions/24852709/how-do-i-automatically-download-files-from-a-pop-up-dialog-using-selenium-python profile.set_preference("browser.download.folderList", 2) profile.set_preference("browser.download.manager.showWhenStarting", False) profile.set_preference("browser.download.dir", self.BROWSER_DOWNLOAD_DIR) profile.set_preference("browser.download.panel.shown", False) profile.set_preference("browser.download.manager.showWhenStarting", False) profile.set_preference("browser.helperApps.alwaysAsk.force", False) #profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/xls;text/csv;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") profile.set_preference( "browser.helperApps.neverAsk.saveToDisk", "application/vnd.hzn-3d-crossword;video/3gpp;video/3gpp2;application/vnd.mseq;application/vnd.3m.post-it-notes;application/vnd.3gpp.pic-bw-large;application/vnd.3gpp.pic-bw-small;application/vnd.3gpp.pic-bw-var;application/vnd.3gp2.tcap;application/x-7z-compressed;application/x-abiword;application/x-ace-compressed;application/vnd.americandynamics.acc;application/vnd.acucobol;application/vnd.acucorp;audio/adpcm;application/x-authorware-bin;application/x-athorware-map;application/x-authorware-seg;application/vnd.adobe.air-application-installer-package+zip;application/x-shockwave-flash;application/vnd.adobe.fxp;application/pdf;application/vnd.cups-ppd;application/x-director;applicaion/vnd.adobe.xdp+xml;application/vnd.adobe.xfdf;audio/x-aac;application/vnd.ahead.space;application/vnd.airzip.filesecure.azf;application/vnd.airzip.filesecure.azs;application/vnd.amazon.ebook;application/vnd.amiga.ami;applicatin/andrew-inset;application/vnd.android.package-archive;application/vnd.anser-web-certificate-issue-initiation;application/vnd.anser-web-funds-transfer-initiation;application/vnd.antix.game-component;application/vnd.apple.installe+xml;application/applixware;application/vnd.hhe.lesson-player;application/vnd.aristanetworks.swi;text/x-asm;application/atomcat+xml;application/atomsvc+xml;application/atom+xml;application/pkix-attr-cert;audio/x-aiff;video/x-msvieo;application/vnd.audiograph;image/vnd.dxf;model/vnd.dwf;text/plain-bas;application/x-bcpio;application/octet-stream;image/bmp;application/x-bittorrent;application/vnd.rim.cod;application/vnd.blueice.multipass;application/vnd.bm;application/x-sh;image/prs.btif;application/vnd.businessobjects;application/x-bzip;application/x-bzip2;application/x-csh;text/x-c;application/vnd.chemdraw+xml;text/css;chemical/x-cdx;chemical/x-cml;chemical/x-csml;application/vn.contact.cmsg;application/vnd.claymore;application/vnd.clonk.c4group;image/vnd.dvb.subtitle;application/cdmi-capability;application/cdmi-container;application/cdmi-domain;application/cdmi-object;application/cdmi-queue;applicationvnd.cluetrust.cartomobile-config;application/vnd.cluetrust.cartomobile-config-pkg;image/x-cmu-raster;model/vnd.collada+xml;text/csv;application/mac-compactpro;application/vnd.wap.wmlc;image/cgm;x-conference/x-cooltalk;image/x-cmx;application/vnd.xara;application/vnd.cosmocaller;application/x-cpio;application/vnd.crick.clicker;application/vnd.crick.clicker.keyboard;application/vnd.crick.clicker.palette;application/vnd.crick.clicker.template;application/vn.crick.clicker.wordbank;application/vnd.criticaltools.wbs+xml;application/vnd.rig.cryptonote;chemical/x-cif;chemical/x-cmdf;application/cu-seeme;application/prs.cww;text/vnd.curl;text/vnd.curl.dcurl;text/vnd.curl.mcurl;text/vnd.crl.scurl;application/vnd.curl.car;application/vnd.curl.pcurl;application/vnd.yellowriver-custom-menu;application/dssc+der;application/dssc+xml;application/x-debian-package;audio/vnd.dece.audio;image/vnd.dece.graphic;video/vnd.dec.hd;video/vnd.dece.mobile;video/vnd.uvvu.mp4;video/vnd.dece.pd;video/vnd.dece.sd;video/vnd.dece.video;application/x-dvi;application/vnd.fdsn.seed;application/x-dtbook+xml;application/x-dtbresource+xml;application/vnd.dvb.ait;applcation/vnd.dvb.service;audio/vnd.digital-winds;image/vnd.djvu;application/xml-dtd;application/vnd.dolby.mlp;application/x-doom;application/vnd.dpgraph;audio/vnd.dra;application/vnd.dreamfactory;audio/vnd.dts;audio/vnd.dts.hd;imag/vnd.dwg;application/vnd.dynageo;application/ecmascript;application/vnd.ecowin.chart;image/vnd.fujixerox.edmics-mmr;image/vnd.fujixerox.edmics-rlc;application/exi;application/vnd.proteus.magazine;application/epub+zip;message/rfc82;application/vnd.enliven;application/vnd.is-xpr;image/vnd.xiff;application/vnd.xfdl;application/emma+xml;application/vnd.ezpix-album;application/vnd.ezpix-package;image/vnd.fst;video/vnd.fvt;image/vnd.fastbidsheet;application/vn.denovo.fcselayout-link;video/x-f4v;video/x-flv;image/vnd.fpx;image/vnd.net-fpx;text/vnd.fmi.flexstor;video/x-fli;application/vnd.fluxtime.clip;application/vnd.fdf;text/x-fortran;application/vnd.mif;application/vnd.framemaker;imae/x-freehand;application/vnd.fsc.weblaunch;application/vnd.frogans.fnc;application/vnd.frogans.ltf;application/vnd.fujixerox.ddd;application/vnd.fujixerox.docuworks;application/vnd.fujixerox.docuworks.binder;application/vnd.fujitu.oasys;application/vnd.fujitsu.oasys2;application/vnd.fujitsu.oasys3;application/vnd.fujitsu.oasysgp;application/vnd.fujitsu.oasysprs;application/x-futuresplash;application/vnd.fuzzysheet;image/g3fax;application/vnd.gmx;model/vn.gtw;application/vnd.genomatix.tuxedo;application/vnd.geogebra.file;application/vnd.geogebra.tool;model/vnd.gdl;application/vnd.geometry-explorer;application/vnd.geonext;application/vnd.geoplan;application/vnd.geospace;applicatio/x-font-ghostscript;application/x-font-bdf;application/x-gtar;application/x-texinfo;application/x-gnumeric;application/vnd.google-earth.kml+xml;application/vnd.google-earth.kmz;application/vnd.grafeq;image/gif;text/vnd.graphviz;aplication/vnd.groove-account;application/vnd.groove-help;application/vnd.groove-identity-message;application/vnd.groove-injector;application/vnd.groove-tool-message;application/vnd.groove-tool-template;application/vnd.groove-vcar;video/h261;video/h263;video/h264;application/vnd.hp-hpid;application/vnd.hp-hps;application/x-hdf;audio/vnd.rip;application/vnd.hbci;application/vnd.hp-jlyt;application/vnd.hp-pcl;application/vnd.hp-hpgl;application/vnd.yamaha.h-script;application/vnd.yamaha.hv-dic;application/vnd.yamaha.hv-voice;application/vnd.hydrostatix.sof-data;application/hyperstudio;application/vnd.hal+xml;text/html;application/vnd.ibm.rights-management;application/vnd.ibm.securecontainer;text/calendar;application/vnd.iccprofile;image/x-icon;application/vnd.igloader;image/ief;application/vnd.immervision-ivp;application/vnd.immervision-ivu;application/reginfo+xml;text/vnd.in3d.3dml;text/vnd.in3d.spot;mode/iges;application/vnd.intergeo;application/vnd.cinderella;application/vnd.intercon.formnet;application/vnd.isac.fcs;application/ipfix;application/pkix-cert;application/pkixcmp;application/pkix-crl;application/pkix-pkipath;applicaion/vnd.insors.igm;application/vnd.ipunplugged.rcprofile;application/vnd.irepository.package+xml;text/vnd.sun.j2me.app-descriptor;application/java-archive;application/java-vm;application/x-java-jnlp-file;application/java-serializd-object;text/x-java-source,java;application/javascript;application/json;application/vnd.joost.joda-archive;video/jpm;image/jpeg;video/jpeg;application/vnd.kahootz;application/vnd.chipnuts.karaoke-mmd;application/vnd.kde.karbon;aplication/vnd.kde.kchart;application/vnd.kde.kformula;application/vnd.kde.kivio;application/vnd.kde.kontour;application/vnd.kde.kpresenter;application/vnd.kde.kspread;application/vnd.kde.kword;application/vnd.kenameaapp;applicatin/vnd.kidspiration;application/vnd.kinar;application/vnd.kodak-descriptor;application/vnd.las.las+xml;application/x-latex;application/vnd.llamagraphics.life-balance.desktop;application/vnd.llamagraphics.life-balance.exchange+xml;application/vnd.jam;application/vnd.lotus-1-2-3;application/vnd.lotus-approach;application/vnd.lotus-freelance;application/vnd.lotus-notes;application/vnd.lotus-organizer;application/vnd.lotus-screencam;application/vnd.lotus-wordro;audio/vnd.lucent.voice;audio/x-mpegurl;video/x-m4v;application/mac-binhex40;application/vnd.macports.portpkg;application/vnd.osgeo.mapguide.package;application/marc;application/marcxml+xml;application/mxf;application/vnd.wolfrm.player;application/mathematica;application/mathml+xml;application/mbox;application/vnd.medcalcdata;application/mediaservercontrol+xml;application/vnd.mediastation.cdkey;application/vnd.mfer;application/vnd.mfmp;model/mesh;appliation/mads+xml;application/mets+xml;application/mods+xml;application/metalink4+xml;application/vnd.ms-powerpoint.template.macroenabled.12;application/vnd.ms-word.document.macroenabled.12;application/vnd.ms-word.template.macroenabed.12;application/vnd.mcd;application/vnd.micrografx.flo;application/vnd.micrografx.igx;application/vnd.eszigno3+xml;application/x-msaccess;video/x-ms-asf;application/x-msdownload;application/vnd.ms-artgalry;application/vnd.ms-ca-compressed;application/vnd.ms-ims;application/x-ms-application;application/x-msclip;image/vnd.ms-modi;application/vnd.ms-fontobject;application/vnd.ms-excel;application/vnd.ms-excel.addin.macroenabled.12;application/vnd.ms-excelsheet.binary.macroenabled.12;application/vnd.ms-excel.template.macroenabled.12;application/vnd.ms-excel.sheet.macroenabled.12;application/vnd.ms-htmlhelp;application/x-mscardfile;application/vnd.ms-lrm;application/x-msmediaview;aplication/x-msmoney;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.slide;application/vnd.openxmlformats-officedocument.presentationml.slideshw;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.openxmformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.wordprocessingml.template;application/x-msbinder;application/vnd.ms-officetheme;application/onenote;audio/vnd.ms-playready.media.pya;vdeo/vnd.ms-playready.media.pyv;application/vnd.ms-powerpoint;application/vnd.ms-powerpoint.addin.macroenabled.12;application/vnd.ms-powerpoint.slide.macroenabled.12;application/vnd.ms-powerpoint.presentation.macroenabled.12;appliation/vnd.ms-powerpoint.slideshow.macroenabled.12;application/vnd.ms-project;application/x-mspublisher;application/x-msschedule;application/x-silverlight-app;application/vnd.ms-pki.stl;application/vnd.ms-pki.seccat;application/vn.visio;video/x-ms-wm;audio/x-ms-wma;audio/x-ms-wax;video/x-ms-wmx;application/x-ms-wmd;application/vnd.ms-wpl;application/x-ms-wmz;video/x-ms-wmv;video/x-ms-wvx;application/x-msmetafile;application/x-msterminal;application/msword;application/x-mswrite;application/vnd.ms-works;application/x-ms-xbap;application/vnd.ms-xpsdocument;audio/midi;application/vnd.ibm.minipay;application/vnd.ibm.modcap;application/vnd.jcp.javame.midlet-rms;application/vnd.tmobile-ivetv;application/x-mobipocket-ebook;application/vnd.mobius.mbk;application/vnd.mobius.dis;application/vnd.mobius.plc;application/vnd.mobius.mqy;application/vnd.mobius.msl;application/vnd.mobius.txf;application/vnd.mobius.daf;tex/vnd.fly;application/vnd.mophun.certificate;application/vnd.mophun.application;video/mj2;audio/mpeg;video/vnd.mpegurl;video/mpeg;application/mp21;audio/mp4;video/mp4;application/mp4;application/vnd.apple.mpegurl;application/vnd.msician;application/vnd.muvee.style;application/xv+xml;application/vnd.nokia.n-gage.data;application/vnd.nokia.n-gage.symbian.install;application/x-dtbncx+xml;application/x-netcdf;application/vnd.neurolanguage.nlu;application/vnd.na;application/vnd.noblenet-directory;application/vnd.noblenet-sealer;application/vnd.noblenet-web;application/vnd.nokia.radio-preset;application/vnd.nokia.radio-presets;text/n3;application/vnd.novadigm.edm;application/vnd.novadim.edx;application/vnd.novadigm.ext;application/vnd.flographit;audio/vnd.nuera.ecelp4800;audio/vnd.nuera.ecelp7470;audio/vnd.nuera.ecelp9600;application/oda;application/ogg;audio/ogg;video/ogg;application/vnd.oma.dd2+xml;applicatin/vnd.oasis.opendocument.text-web;application/oebps-package+xml;application/vnd.intu.qbo;application/vnd.openofficeorg.extension;application/vnd.yamaha.openscoreformat;audio/webm;video/webm;application/vnd.oasis.opendocument.char;application/vnd.oasis.opendocument.chart-template;application/vnd.oasis.opendocument.database;application/vnd.oasis.opendocument.formula;application/vnd.oasis.opendocument.formula-template;application/vnd.oasis.opendocument.grapics;application/vnd.oasis.opendocument.graphics-template;application/vnd.oasis.opendocument.image;application/vnd.oasis.opendocument.image-template;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocumen.presentation-template;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.text-master;application/vnd.asis.opendocument.text-template;image/ktx;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/vnd.sun.xml.draw;application/vnd.sun.xml.draw.template;application/vnd.sun.xml.impress;application/vnd.sun.xl.impress.template;application/vnd.sun.xml.math;application/vnd.sun.xml.writer;application/vnd.sun.xml.writer.global;application/vnd.sun.xml.writer.template;application/x-font-otf;application/vnd.yamaha.openscoreformat.osfpvg+xml;application/vnd.osgi.dp;application/vnd.palm;text/x-pascal;application/vnd.pawaafile;application/vnd.hp-pclxl;application/vnd.picsel;image/x-pcx;image/vnd.adobe.photoshop;application/pics-rules;image/x-pict;application/x-chat;aplication/pkcs10;application/x-pkcs12;application/pkcs7-mime;application/pkcs7-signature;application/x-pkcs7-certreqresp;application/x-pkcs7-certificates;application/pkcs8;application/vnd.pocketlearn;image/x-portable-anymap;image/-portable-bitmap;application/x-font-pcf;application/font-tdpfr;application/x-chess-pgn;image/x-portable-graymap;image/png;image/x-portable-pixmap;application/pskc+xml;application/vnd.ctc-posml;application/postscript;application/xfont-type1;application/vnd.powerbuilder6;application/pgp-encrypted;application/pgp-signature;application/vnd.previewsystems.box;application/vnd.pvi.ptid1;application/pls+xml;application/vnd.pg.format;application/vnd.pg.osasli;tex/prs.lines.tag;application/x-font-linux-psf;application/vnd.publishare-delta-tree;application/vnd.pmi.widget;application/vnd.quark.quarkxpress;application/vnd.epson.esf;application/vnd.epson.msf;application/vnd.epson.ssf;applicaton/vnd.epson.quickanime;application/vnd.intu.qfx;video/quicktime;application/x-rar-compressed;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;application/rsd+xml;application/vnd.rn-realmedia;application/vnd.realvnc.bed;applicatin/vnd.recordare.musicxml;application/vnd.recordare.musicxml+xml;application/relax-ng-compact-syntax;application/vnd.data-vision.rdz;application/rdf+xml;application/vnd.cloanto.rp9;application/vnd.jisp;application/rtf;text/richtex;application/vnd.route66.link66+xml;application/rss+xml;application/shf+xml;application/vnd.sailingtracker.track;image/svg+xml;application/vnd.sus-calendar;application/sru+xml;application/set-payment-initiation;application/set-reistration-initiation;application/vnd.sema;application/vnd.semd;application/vnd.semf;application/vnd.seemail;application/x-font-snf;application/scvp-vp-request;application/scvp-vp-response;application/scvp-cv-request;application/svp-cv-response;application/sdp;text/x-setext;video/x-sgi-movie;application/vnd.shana.informed.formdata;application/vnd.shana.informed.formtemplate;application/vnd.shana.informed.interchange;application/vnd.shana.informed.package;application/thraud+xml;application/x-shar;image/x-rgb;application/vnd.epson.salt;application/vnd.accpac.simply.aso;application/vnd.accpac.simply.imp;application/vnd.simtech-mindmapper;application/vnd.commonspace;application/vnd.ymaha.smaf-audio;application/vnd.smaf;application/vnd.yamaha.smaf-phrase;application/vnd.smart.teacher;application/vnd.svd;application/sparql-query;application/sparql-results+xml;application/srgs;application/srgs+xml;application/sml+xml;application/vnd.koan;text/sgml;application/vnd.stardivision.calc;application/vnd.stardivision.draw;application/vnd.stardivision.impress;application/vnd.stardivision.math;application/vnd.stardivision.writer;application/vnd.tardivision.writer-global;application/vnd.stepmania.stepchart;application/x-stuffit;application/x-stuffitx;application/vnd.solent.sdkm+xml;application/vnd.olpc-sugar;audio/basic;application/vnd.wqd;application/vnd.symbian.install;application/smil+xml;application/vnd.syncml+xml;application/vnd.syncml.dm+wbxml;application/vnd.syncml.dm+xml;application/x-sv4cpio;application/x-sv4crc;application/sbml+xml;text/tab-separated-values;image/tiff;application/vnd.to.intent-module-archive;application/x-tar;application/x-tcl;application/x-tex;application/x-tex-tfm;application/tei+xml;text/plain;application/vnd.spotfire.dxp;application/vnd.spotfire.sfs;application/timestamped-data;applicationvnd.trid.tpt;application/vnd.triscape.mxs;text/troff;application/vnd.trueapp;application/x-font-ttf;text/turtle;application/vnd.umajin;application/vnd.uoml+xml;application/vnd.unity;application/vnd.ufdl;text/uri-list;application/nd.uiq.theme;application/x-ustar;text/x-uuencode;text/x-vcalendar;text/x-vcard;application/x-cdlink;application/vnd.vsf;model/vrml;application/vnd.vcx;model/vnd.mts;model/vnd.vtu;application/vnd.visionary;video/vnd.vivo;applicatin/ccxml+xml,;application/voicexml+xml;application/x-wais-source;application/vnd.wap.wbxml;image/vnd.wap.wbmp;audio/x-wav;application/davmount+xml;application/x-font-woff;application/wspolicy+xml;image/webp;application/vnd.webturb;application/widget;application/winhlp;text/vnd.wap.wml;text/vnd.wap.wmlscript;application/vnd.wap.wmlscriptc;application/vnd.wordperfect;application/vnd.wt.stf;application/wsdl+xml;image/x-xbitmap;image/x-xpixmap;image/x-xwindowump;application/x-x509-ca-cert;application/x-xfig;application/xhtml+xml;application/xml;application/xcap-diff+xml;application/xenc+xml;application/patch-ops-error+xml;application/resource-lists+xml;application/rls-services+xml;aplication/resource-lists-diff+xml;application/xslt+xml;application/xop+xml;application/x-xpinstall;application/xspf+xml;application/vnd.mozilla.xul+xml;chemical/x-xyz;text/yaml;application/yang;application/yin+xml;application/vnd.ul;application/zip;application/vnd.handheld-entertainment+xml;application/vnd.zzazz.deck+xml;text/csv,application/vnd.ms-excel,text/plain,application/xls,application/xlss,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/x-xls,application/excel,application/x-excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel" ) #"application/vnd.hzn-3d-crossword;video/3gpp;video/3gpp2;application/vnd.mseq;application/vnd.3m.post-it-notes;application/vnd.3gpp.pic-bw-large;application/vnd.3gpp.pic-bw-small;application/vnd.3gpp.pic-bw-var;application/vnd.3gp2.tcap;application/x-7z-compressed;application/x-abiword;application/x-ace-compressed;application/vnd.americandynamics.acc;application/vnd.acucobol;application/vnd.acucorp;audio/adpcm;application/x-authorware-bin;application/x-athorware-map;application/x-authorware-seg;application/vnd.adobe.air-application-installer-package+zip;application/x-shockwave-flash;application/vnd.adobe.fxp;application/pdf;application/vnd.cups-ppd;application/x-director;applicaion/vnd.adobe.xdp+xml;application/vnd.adobe.xfdf;audio/x-aac;application/vnd.ahead.space;application/vnd.airzip.filesecure.azf;application/vnd.airzip.filesecure.azs;application/vnd.amazon.ebook;application/vnd.amiga.ami;applicatin/andrew-inset;application/vnd.android.package-archive;application/vnd.anser-web-certificate-issue-initiation;application/vnd.anser-web-funds-transfer-initiation;application/vnd.antix.game-component;application/vnd.apple.installe+xml;application/applixware;application/vnd.hhe.lesson-player;application/vnd.aristanetworks.swi;text/x-asm;application/atomcat+xml;application/atomsvc+xml;application/atom+xml;application/pkix-attr-cert;audio/x-aiff;video/x-msvieo;application/vnd.audiograph;image/vnd.dxf;model/vnd.dwf;text/plain-bas;application/x-bcpio;application/octet-stream;image/bmp;application/x-bittorrent;application/vnd.rim.cod;application/vnd.blueice.multipass;application/vnd.bm;application/x-sh;image/prs.btif;application/vnd.businessobjects;application/x-bzip;application/x-bzip2;application/x-csh;text/x-c;application/vnd.chemdraw+xml;text/css;chemical/x-cdx;chemical/x-cml;chemical/x-csml;application/vn.contact.cmsg;application/vnd.claymore;application/vnd.clonk.c4group;image/vnd.dvb.subtitle;application/cdmi-capability;application/cdmi-container;application/cdmi-domain;application/cdmi-object;application/cdmi-queue;applicationvnd.cluetrust.cartomobile-config;application/vnd.cluetrust.cartomobile-config-pkg;image/x-cmu-raster;model/vnd.collada+xml;text/csv;application/mac-compactpro;application/vnd.wap.wmlc;image/cgm;x-conference/x-cooltalk;image/x-cmx;application/vnd.xara;application/vnd.cosmocaller;application/x-cpio;application/vnd.crick.clicker;application/vnd.crick.clicker.keyboard;application/vnd.crick.clicker.palette;application/vnd.crick.clicker.template;application/vn.crick.clicker.wordbank;application/vnd.criticaltools.wbs+xml;application/vnd.rig.cryptonote;chemical/x-cif;chemical/x-cmdf;application/cu-seeme;application/prs.cww;text/vnd.curl;text/vnd.curl.dcurl;text/vnd.curl.mcurl;text/vnd.crl.scurl;application/vnd.curl.car;application/vnd.curl.pcurl;application/vnd.yellowriver-custom-menu;application/dssc+der;application/dssc+xml;application/x-debian-package;audio/vnd.dece.audio;image/vnd.dece.graphic;video/vnd.dec.hd;video/vnd.dece.mobile;video/vnd.uvvu.mp4;video/vnd.dece.pd;video/vnd.dece.sd;video/vnd.dece.video;application/x-dvi;application/vnd.fdsn.seed;application/x-dtbook+xml;application/x-dtbresource+xml;application/vnd.dvb.ait;applcation/vnd.dvb.service;audio/vnd.digital-winds;image/vnd.djvu;application/xml-dtd;application/vnd.dolby.mlp;application/x-doom;application/vnd.dpgraph;audio/vnd.dra;application/vnd.dreamfactory;audio/vnd.dts;audio/vnd.dts.hd;imag/vnd.dwg;application/vnd.dynageo;application/ecmascript;application/vnd.ecowin.chart;image/vnd.fujixerox.edmics-mmr;image/vnd.fujixerox.edmics-rlc;application/exi;application/vnd.proteus.magazine;application/epub+zip;message/rfc82;application/vnd.enliven;application/vnd.is-xpr;image/vnd.xiff;application/vnd.xfdl;application/emma+xml;application/vnd.ezpix-album;application/vnd.ezpix-package;image/vnd.fst;video/vnd.fvt;image/vnd.fastbidsheet;application/vn.denovo.fcselayout-link;video/x-f4v;video/x-flv;image/vnd.fpx;image/vnd.net-fpx;text/vnd.fmi.flexstor;video/x-fli;application/vnd.fluxtime.clip;application/vnd.fdf;text/x-fortran;application/vnd.mif;application/vnd.framemaker;imae/x-freehand;application/vnd.fsc.weblaunch;application/vnd.frogans.fnc;application/vnd.frogans.ltf;application/vnd.fujixerox.ddd;application/vnd.fujixerox.docuworks;application/vnd.fujixerox.docuworks.binder;application/vnd.fujitu.oasys;application/vnd.fujitsu.oasys2;application/vnd.fujitsu.oasys3;application/vnd.fujitsu.oasysgp;application/vnd.fujitsu.oasysprs;application/x-futuresplash;application/vnd.fuzzysheet;image/g3fax;application/vnd.gmx;model/vn.gtw;application/vnd.genomatix.tuxedo;application/vnd.geogebra.file;application/vnd.geogebra.tool;model/vnd.gdl;application/vnd.geometry-explorer;application/vnd.geonext;application/vnd.geoplan;application/vnd.geospace;applicatio/x-font-ghostscript;application/x-font-bdf;application/x-gtar;application/x-texinfo;application/x-gnumeric;application/vnd.google-earth.kml+xml;application/vnd.google-earth.kmz;application/vnd.grafeq;image/gif;text/vnd.graphviz;aplication/vnd.groove-account;application/vnd.groove-help;application/vnd.groove-identity-message;application/vnd.groove-injector;application/vnd.groove-tool-message;application/vnd.groove-tool-template;application/vnd.groove-vcar;video/h261;video/h263;video/h264;application/vnd.hp-hpid;application/vnd.hp-hps;application/x-hdf;audio/vnd.rip;application/vnd.hbci;application/vnd.hp-jlyt;application/vnd.hp-pcl;application/vnd.hp-hpgl;application/vnd.yamaha.h-script;application/vnd.yamaha.hv-dic;application/vnd.yamaha.hv-voice;application/vnd.hydrostatix.sof-data;application/hyperstudio;application/vnd.hal+xml;text/html;application/vnd.ibm.rights-management;application/vnd.ibm.securecontainer;text/calendar;application/vnd.iccprofile;image/x-icon;application/vnd.igloader;image/ief;application/vnd.immervision-ivp;application/vnd.immervision-ivu;application/reginfo+xml;text/vnd.in3d.3dml;text/vnd.in3d.spot;mode/iges;application/vnd.intergeo;application/vnd.cinderella;application/vnd.intercon.formnet;application/vnd.isac.fcs;application/ipfix;application/pkix-cert;application/pkixcmp;application/pkix-crl;application/pkix-pkipath;applicaion/vnd.insors.igm;application/vnd.ipunplugged.rcprofile;application/vnd.irepository.package+xml;text/vnd.sun.j2me.app-descriptor;application/java-archive;application/java-vm;application/x-java-jnlp-file;application/java-serializd-object;text/x-java-source,java;application/javascript;application/json;application/vnd.joost.joda-archive;video/jpm;image/jpeg;video/jpeg;application/vnd.kahootz;application/vnd.chipnuts.karaoke-mmd;application/vnd.kde.karbon;aplication/vnd.kde.kchart;application/vnd.kde.kformula;application/vnd.kde.kivio;application/vnd.kde.kontour;application/vnd.kde.kpresenter;application/vnd.kde.kspread;application/vnd.kde.kword;application/vnd.kenameaapp;applicatin/vnd.kidspiration;application/vnd.kinar;application/vnd.kodak-descriptor;application/vnd.las.las+xml;application/x-latex;application/vnd.llamagraphics.life-balance.desktop;application/vnd.llamagraphics.life-balance.exchange+xml;application/vnd.jam;application/vnd.lotus-1-2-3;application/vnd.lotus-approach;application/vnd.lotus-freelance;application/vnd.lotus-notes;application/vnd.lotus-organizer;application/vnd.lotus-screencam;application/vnd.lotus-wordro;audio/vnd.lucent.voice;audio/x-mpegurl;video/x-m4v;application/mac-binhex40;application/vnd.macports.portpkg;application/vnd.osgeo.mapguide.package;application/marc;application/marcxml+xml;application/mxf;application/vnd.wolfrm.player;application/mathematica;application/mathml+xml;application/mbox;application/vnd.medcalcdata;application/mediaservercontrol+xml;application/vnd.mediastation.cdkey;application/vnd.mfer;application/vnd.mfmp;model/mesh;appliation/mads+xml;application/mets+xml;application/mods+xml;application/metalink4+xml;application/vnd.ms-powerpoint.template.macroenabled.12;application/vnd.ms-word.document.macroenabled.12;application/vnd.ms-word.template.macroenabed.12;application/vnd.mcd;application/vnd.micrografx.flo;application/vnd.micrografx.igx;application/vnd.eszigno3+xml;application/x-msaccess;video/x-ms-asf;application/x-msdownload;application/vnd.ms-artgalry;application/vnd.ms-ca-compressed;application/vnd.ms-ims;application/x-ms-application;application/x-msclip;image/vnd.ms-modi;application/vnd.ms-fontobject;application/vnd.ms-excel;application/vnd.ms-excel.addin.macroenabled.12;application/vnd.ms-excelsheet.binary.macroenabled.12;application/vnd.ms-excel.template.macroenabled.12;application/vnd.ms-excel.sheet.macroenabled.12;application/vnd.ms-htmlhelp;application/x-mscardfile;application/vnd.ms-lrm;application/x-msmediaview;aplication/x-msmoney;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.slide;application/vnd.openxmlformats-officedocument.presentationml.slideshw;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.openxmformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.wordprocessingml.template;application/x-msbinder;application/vnd.ms-officetheme;application/onenote;audio/vnd.ms-playready.media.pya;vdeo/vnd.ms-playready.media.pyv;application/vnd.ms-powerpoint;application/vnd.ms-powerpoint.addin.macroenabled.12;application/vnd.ms-powerpoint.slide.macroenabled.12;application/vnd.ms-powerpoint.presentation.macroenabled.12;appliation/vnd.ms-powerpoint.slideshow.macroenabled.12;application/vnd.ms-project;application/x-mspublisher;application/x-msschedule;application/x-silverlight-app;application/vnd.ms-pki.stl;application/vnd.ms-pki.seccat;application/vn.visio;video/x-ms-wm;audio/x-ms-wma;audio/x-ms-wax;video/x-ms-wmx;application/x-ms-wmd;application/vnd.ms-wpl;application/x-ms-wmz;video/x-ms-wmv;video/x-ms-wvx;application/x-msmetafile;application/x-msterminal;application/msword;application/x-mswrite;application/vnd.ms-works;application/x-ms-xbap;application/vnd.ms-xpsdocument;audio/midi;application/vnd.ibm.minipay;application/vnd.ibm.modcap;application/vnd.jcp.javame.midlet-rms;application/vnd.tmobile-ivetv;application/x-mobipocket-ebook;application/vnd.mobius.mbk;application/vnd.mobius.dis;application/vnd.mobius.plc;application/vnd.mobius.mqy;application/vnd.mobius.msl;application/vnd.mobius.txf;application/vnd.mobius.daf;tex/vnd.fly;application/vnd.mophun.certificate;application/vnd.mophun.application;video/mj2;audio/mpeg;video/vnd.mpegurl;video/mpeg;application/mp21;audio/mp4;video/mp4;application/mp4;application/vnd.apple.mpegurl;application/vnd.msician;application/vnd.muvee.style;application/xv+xml;application/vnd.nokia.n-gage.data;application/vnd.nokia.n-gage.symbian.install;application/x-dtbncx+xml;application/x-netcdf;application/vnd.neurolanguage.nlu;application/vnd.na;application/vnd.noblenet-directory;application/vnd.noblenet-sealer;application/vnd.noblenet-web;application/vnd.nokia.radio-preset;application/vnd.nokia.radio-presets;text/n3;application/vnd.novadigm.edm;application/vnd.novadim.edx;application/vnd.novadigm.ext;application/vnd.flographit;audio/vnd.nuera.ecelp4800;audio/vnd.nuera.ecelp7470;audio/vnd.nuera.ecelp9600;application/oda;application/ogg;audio/ogg;video/ogg;application/vnd.oma.dd2+xml;applicatin/vnd.oasis.opendocument.text-web;application/oebps-package+xml;application/vnd.intu.qbo;application/vnd.openofficeorg.extension;application/vnd.yamaha.openscoreformat;audio/webm;video/webm;application/vnd.oasis.opendocument.char;application/vnd.oasis.opendocument.chart-template;application/vnd.oasis.opendocument.database;application/vnd.oasis.opendocument.formula;application/vnd.oasis.opendocument.formula-template;application/vnd.oasis.opendocument.grapics;application/vnd.oasis.opendocument.graphics-template;application/vnd.oasis.opendocument.image;application/vnd.oasis.opendocument.image-template;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocumen.presentation-template;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.text-master;application/vnd.asis.opendocument.text-template;image/ktx;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/vnd.sun.xml.draw;application/vnd.sun.xml.draw.template;application/vnd.sun.xml.impress;application/vnd.sun.xl.impress.template;application/vnd.sun.xml.math;application/vnd.sun.xml.writer;application/vnd.sun.xml.writer.global;application/vnd.sun.xml.writer.template;application/x-font-otf;application/vnd.yamaha.openscoreformat.osfpvg+xml;application/vnd.osgi.dp;application/vnd.palm;text/x-pascal;application/vnd.pawaafile;application/vnd.hp-pclxl;application/vnd.picsel;image/x-pcx;image/vnd.adobe.photoshop;application/pics-rules;image/x-pict;application/x-chat;aplication/pkcs10;application/x-pkcs12;application/pkcs7-mime;application/pkcs7-signature;application/x-pkcs7-certreqresp;application/x-pkcs7-certificates;application/pkcs8;application/vnd.pocketlearn;image/x-portable-anymap;image/-portable-bitmap;application/x-font-pcf;application/font-tdpfr;application/x-chess-pgn;image/x-portable-graymap;image/png;image/x-portable-pixmap;application/pskc+xml;application/vnd.ctc-posml;application/postscript;application/xfont-type1;application/vnd.powerbuilder6;application/pgp-encrypted;application/pgp-signature;application/vnd.previewsystems.box;application/vnd.pvi.ptid1;application/pls+xml;application/vnd.pg.format;application/vnd.pg.osasli;tex/prs.lines.tag;application/x-font-linux-psf;application/vnd.publishare-delta-tree;application/vnd.pmi.widget;application/vnd.quark.quarkxpress;application/vnd.epson.esf;application/vnd.epson.msf;application/vnd.epson.ssf;applicaton/vnd.epson.quickanime;application/vnd.intu.qfx;video/quicktime;application/x-rar-compressed;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;application/rsd+xml;application/vnd.rn-realmedia;application/vnd.realvnc.bed;applicatin/vnd.recordare.musicxml;application/vnd.recordare.musicxml+xml;application/relax-ng-compact-syntax;application/vnd.data-vision.rdz;application/rdf+xml;application/vnd.cloanto.rp9;application/vnd.jisp;application/rtf;text/richtex;application/vnd.route66.link66+xml;application/rss+xml;application/shf+xml;application/vnd.sailingtracker.track;image/svg+xml;application/vnd.sus-calendar;application/sru+xml;application/set-payment-initiation;application/set-reistration-initiation;application/vnd.sema;application/vnd.semd;application/vnd.semf;application/vnd.seemail;application/x-font-snf;application/scvp-vp-request;application/scvp-vp-response;application/scvp-cv-request;application/svp-cv-response;application/sdp;text/x-setext;video/x-sgi-movie;application/vnd.shana.informed.formdata;application/vnd.shana.informed.formtemplate;application/vnd.shana.informed.interchange;application/vnd.shana.informed.package;application/thraud+xml;application/x-shar;image/x-rgb;application/vnd.epson.salt;application/vnd.accpac.simply.aso;application/vnd.accpac.simply.imp;application/vnd.simtech-mindmapper;application/vnd.commonspace;application/vnd.ymaha.smaf-audio;application/vnd.smaf;application/vnd.yamaha.smaf-phrase;application/vnd.smart.teacher;application/vnd.svd;application/sparql-query;application/sparql-results+xml;application/srgs;application/srgs+xml;application/sml+xml;application/vnd.koan;text/sgml;application/vnd.stardivision.calc;application/vnd.stardivision.draw;application/vnd.stardivision.impress;application/vnd.stardivision.math;application/vnd.stardivision.writer;application/vnd.tardivision.writer-global;application/vnd.stepmania.stepchart;application/x-stuffit;application/x-stuffitx;application/vnd.solent.sdkm+xml;application/vnd.olpc-sugar;audio/basic;application/vnd.wqd;application/vnd.symbian.install;application/smil+xml;application/vnd.syncml+xml;application/vnd.syncml.dm+wbxml;application/vnd.syncml.dm+xml;application/x-sv4cpio;application/x-sv4crc;application/sbml+xml;text/tab-separated-values;image/tiff;application/vnd.to.intent-module-archive;application/x-tar;application/x-tcl;application/x-tex;application/x-tex-tfm;application/tei+xml;text/plain;application/vnd.spotfire.dxp;application/vnd.spotfire.sfs;application/timestamped-data;applicationvnd.trid.tpt;application/vnd.triscape.mxs;text/troff;application/vnd.trueapp;application/x-font-ttf;text/turtle;application/vnd.umajin;application/vnd.uoml+xml;application/vnd.unity;application/vnd.ufdl;text/uri-list;application/nd.uiq.theme;application/x-ustar;text/x-uuencode;text/x-vcalendar;text/x-vcard;application/x-cdlink;application/vnd.vsf;model/vrml;application/vnd.vcx;model/vnd.mts;model/vnd.vtu;application/vnd.visionary;video/vnd.vivo;applicatin/ccxml+xml,;application/voicexml+xml;application/x-wais-source;application/vnd.wap.wbxml;image/vnd.wap.wbmp;audio/x-wav;application/davmount+xml;application/x-font-woff;application/wspolicy+xml;image/webp;application/vnd.webturb;application/widget;application/winhlp;text/vnd.wap.wml;text/vnd.wap.wmlscript;application/vnd.wap.wmlscriptc;application/vnd.wordperfect;application/vnd.wt.stf;application/wsdl+xml;image/x-xbitmap;image/x-xpixmap;image/x-xwindowump;application/x-x509-ca-cert;application/x-xfig;application/xhtml+xml;application/xml;application/xcap-diff+xml;application/xenc+xml;application/patch-ops-error+xml;application/resource-lists+xml;application/rls-services+xml;aplication/resource-lists-diff+xml;application/xslt+xml;application/xop+xml;application/x-xpinstall;application/xspf+xml;application/vnd.mozilla.xul+xml;chemical/x-xyz;text/yaml;application/yang;application/yin+xml;application/vnd.ul;application/zip;application/vnd.handheld-entertainment+xml;application/vnd.zzazz.deck+xml") #profile.set_preference("browser.helperApps.neverAsk.openFile","text/csv,application/vnd.ms-excel,text/plain,application/xls,application/xlss,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/x-xls,application/excel,application/x-excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel") #profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/vnd.ms-excel,text/plain,application/xls,application/xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/x-xls,application/excel,application/x-excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel") #profile.set_preference("browser.helperApps.neverAsk.saveToDisk","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") #profile.set_preference("browser.helperApps.neverAsk.saveToDisk","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") options = webdriver.firefox.options.Options() if "True" in self.HEADLESS: options.add_argument("--headless") binary = FirefoxBinary('./firefox/firefox') #driver = webdriver.Firefox(firefox_binary=binary) driver = webdriver.Firefox(firefox_options=options, firefox_profile=profile, executable_path="./geckodriver", firefox_binary=binary) #self.web_driver = getattr(webdriver,self.BROWSER)(firefox_profile=profile) self.web_driver = driver if "Chrome" in self.BROWSER: self.logger.info("Using chrome") # installedChrome = parentDir +".virtenv-remote/chromedriver" if self.BROWSER_AUTO_INSTALL == "True": from webdriver_manager.chrome import ChromeDriverManager installedChrome = ChromeDriverManager().install() else: installedChrome = self.BASE_PATH + self.DRIVER_FILE_PATH from selenium.webdriver.chrome.options import Options opt = Options() opt.add_argument("--disable-infobars") # opt.add_argument("start-maximized") opt.add_argument("--disable-extensions") opt.add_argument("--no-sandbox") opt.add_argument("--user-data-dir=" + self.BROWSER_PROFILE_DIR) if "True" in self.HEADLESS: opt.add_argument("--headless") # Pass the argument 1 to allow and 2 to block opt.add_experimental_option("prefs", { \ "profile.default_content_setting_values.media_stream_mic": 1, "profile.default_content_setting_values.media_stream_camera": 1, "profile.default_content_setting_values.geolocation": 1, "profile.default_content_setting_values.notifications": 1 }) self.logger.info("installedChrome path: " + installedChrome) self.web_driver = webdriver.Chrome(executable_path=installedChrome, chrome_options=opt) return
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.firefox.options import Options from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.keys import Keys from time import sleep # enable browser logging d = DesiredCapabilities.CHROME d['goog:loggingPrefs'] = {'browser': 'ALL'} options = webdriver.ChromeOptions() options.add_argument('--headless') options.add_argument('--no-sandbox') # options.add_argument("start-maximized") options.add_argument("--window-size=1920,1080") options.add_argument("--auto-open-devtools-for-tabs") options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_experimental_option('useAutomationExtension', False) driver = webdriver.Chrome(desired_capabilities=d, options=options) # load the desired webpage driver.get('https://banggia.vps.com.vn/#PhaiSinh/VN30') sleep(3) driver.execute_script( """document.querySelector("#sym_VN30F2011 > a").click()""") sleep(1) driver.get_screenshot_as_file("/home/sotola/Desktop/screenshot.png") # https://stackoverflow.com/questions/20907180/getting-console-log-output-from-chrome-with-selenium-python-api-bindings sleep(1) driver.execute_script("""// Scrape phai sinh 1s function grabVn30List() { data = grabData("/html/body/div[2]/div/div/div[2]/div/div/table/tbody");
def main(): global proxy_client, proxy_server LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s" log_filename = 'logs/test_' + time.strftime("%Y%m%d", time.localtime()) + '.log' logging.basicConfig(filename=log_filename, level=logging.INFO, format=LOG_FORMAT) # 当前脚本所在目录路径 path = os.path.dirname(os.path.realpath(__file__)) test_config = TestConfig(path) if len(sys.argv) > 1: report_name = sys.argv[1] if 'ls' == sys.argv[1]: files = getFileName(path + '/config/') print(Util.pretty(files)) return else: report_name = 'default' # 获取测试用例数据 config = test_config.get_test_case(sys.argv) # 是否开启代理 is_open_proxy = config.get('BROWSER').get('proxy') if is_open_proxy: from browsermobproxy import Server bmp_path = config.get('BROWSER').get('bmp_path') logging.info('开启代理 ' + bmp_path) proxy_server = Server(bmp_path) proxy_server.start() proxy_client = proxy_server.create_proxy() # 浏览器类型 browser_type = config.get('BROWSER').get('type') # 是否使用H5测试,并指定移动设备名称 h5 = config.get('BROWSER').get('H5', False) device_name = config.get('BROWSER').get('device_name', 'iPhone 7') # 是否开启无头模式 headless = config.get('BROWSER').get('headless', False) if browser_type == 'Firefox': options = FirefoxOptions() if headless: options.add_argument("-headless") options.page_load_strategy = 'normal' if h5: user_agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" options.set_preference("general.useragent.override", user_agent) if is_open_proxy: options.add_argument('--proxy-server={0}'.format( proxy_client.proxy)) browser = webdriver.Firefox(options=options) elif browser_type == 'Chrome': options = ChromeOptions() if headless: options.add_argument("--window-size=1920,1080") # 设置浏览器分辨率(窗口大小) options.add_argument( "--start-maximized") # 最大化运行(全屏窗口),不设置,获取元素可能会报错 options.add_argument("--disable-extensions") options.add_argument('--no-sandbox') # 取消沙盒模式,浏览器的安全性会降低 # 禁用GPU加速,降低资源损耗,only for Windows but not a valid configuration for Linux OS options.add_argument('--disable-gpu') options.add_argument('--disable-dev-shm-usage') # 解决资源有限的问题 options.add_argument('--lang=en_US') options.add_argument("--headless") options.page_load_strategy = 'normal' if h5: mobileEmulation = {'deviceName': device_name} options.add_experimental_option('mobileEmulation', mobileEmulation) if is_open_proxy: options.add_argument('--proxy-server={0}'.format( proxy_client.proxy)) browser = webdriver.Chrome(options=options) else: print('浏览器' + browser_type + ':类型不支持') return False logging.info('开始使用 ' + browser_type + ' 浏览器进行自动化测试') if is_open_proxy: proxy_client.new_har("req", options={ 'captureHeaders': True, 'captureContent': True }) if browser_type == 'Firefox' and h5: browser.set_window_size(360, 640) else: browser.maximize_window() # 浏览器等待时间 # browser.implicitly_wait(10) url = config.get('WEBSITE').get('url') browser.get(url) if is_open_proxy: Http.logHar(proxy_client.har) # 执行配置的TEST对象 test = config.get('TEST') suite = unittest.TestSuite() m = Menu() for key in test: menus = m.getMenuConfig(config, key) try: if is_open_proxy: test_data = [browser, menus, proxy_client] else: test_data = [browser, menus] suite.addTest( ParametrizedTestCase.parametrize(Action, 'test_menu', param=test_data)) except AssertExcetion: print(key + " 断言失败") # 是否生成报告,默认开启调试模式,不生成报告 debug = config.get('DEBUG', True) if debug: runner = unittest.TextTestRunner() runner.run(suite) else: # 报告是否含有截图,DEBUG为False且IMAGE设置为True时生效 image = config.get('IMAGE', False) report_path = path + '/reports/' report_file = report_name + "_" + time.strftime( "%Y%m%d", time.localtime()) + '.html' fp = open(report_path + report_file, 'wb') report_title = '你的测试报告' report_desc = '使用配置:' + report_name + '生成的测试报告' runner = HTMLTestRunner(stream=fp, verbosity=2, images=image, title=report_title, description=report_desc, tester='pystest') runner.run(suite) fp.close() sleep(5) browser.quit() # send mail or not mail = config.get('MAIL') if not debug and mail and mail.get('SEND'): email_title = report_title email_content = report_desc smtp = Mail(config.get('MAIL'), report_path) smtp.connect() smtp.login() smtp.send(email_title, email_content, report_file) smtp.quit() if is_open_proxy: proxy_client.close() proxy_server.stop()
class Downloader(): def __init__(self, choice): self.choice = choice self.file_path = download_path() self.titles = [] self.video_url = '' self.browser_name = '' # Firefox Options from selenium.webdriver.firefox.firefox_profile import FirefoxProfile from selenium.webdriver.firefox.options import Options self.profile = webdriver.FirefoxProfile() self.profile.set_preference( "browser.download.manager.showWhenStarting", False) self.profile.set_preference( "browser.download.manager.showAlertOnComplete", False) self.profile.set_preference("media.volume_scale", "0.0") self.profile.set_preference("browser.download.dir", self.file_path) if choice == 'mp3': self.profile.set_preference( "browser.helperApps.neverAsk.saveToDisk", "audio/mpeg") elif choice == 'mp4': self.profile.set_preference( "browser.helperApps.neverAsk.saveToDisk", "video/mp4") self.firefox_options = Options() self.firefox_options.set_headless() assert self.firefox_options.headless self.firefox_options.add_argument('disable-gpu') self.firefox_options.set_preference("dom.webnotifications.enabled", False) # Chrome Options from selenium.webdriver.chrome.options import Options self.chrome_options = Options() self.chrome_options.add_experimental_option( "prefs", { "download.default_directory": self.file_path, "download.prompt_for_download": False, }) self.chrome_options.add_argument("headless") self.chrome_options.add_argument('disable-gpu') self.chrome_options.add_argument('--disable-extensions') self.chrome_options.add_argument("--disable-notifications") self.chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']) try: self.browser = webdriver.Firefox(executable_path=os.getcwd() + "\\Drivers\\geckodriver.exe", firefox_profile=self.profile, options=self.firefox_options) self.browser_name = 'Firefox' except: try: self.browser = webdriver.Chrome( executable_path=os.getcwd() + "\\Drivers\\80\\chromedriver.exe", chrome_options=self.chrome_options) self.browser_name = 'Chrome' except: try: self.browser = webdriver.Chrome( executable_path=os.getcwd() + "\\Drivers\\79\\chromedriver.exe", chrome_options=self.chrome_options) self.browser_name = 'Chrome' except: print("Problem with browser") def launch_youtube(self): url = 'https://youtube.com' connected = False while not connected: try: self.browser.get(url) connected = True except: time.sleep(1) def search_youtube(self, string): connected = False while not connected: try: box = self.browser.find_element_by_name('search_query') connected = True except: time.sleep(1) box.send_keys(string) time.sleep(2) connected = False while not connected: try: button = self.browser.find_element_by_id('search-icon-legacy') connected = True except: time.sleep(1) button.click() time.sleep(2) self.browser.get(self.browser.current_url) time.sleep(2) def get_titles(self): connected = False while not connected: try: titles = self.browser.find_elements_by_xpath( '//*[@id="video-title"]') connected = True except: time.sleep(1) i = 0 for title in titles: name = title.get_attribute('title') # Unicode Protection for char in name: if (ord(char) > 65536): name = '' self.titles.append(name) if (i == 4): break i += 1 def find_video(self, path): connected = False while not connected: try: video = self.browser.find_element_by_xpath(path) video.click() connected = True except: time.sleep(2) self.video_url = self.browser.current_url def launch_downloader(self): url = 'https://ytmp3.cc/en13/' connected = False while not connected: try: self.browser.get(url) connected = True except: time.sleep(2) def download(self): if (self.choice == 'mp3'): mp3 = self.browser.find_element_by_xpath('//*[@id="mp3"]') mp3.click() time.sleep(2) elif (self.choice == 'mp4'): mp4 = self.browser.find_element_by_xpath('//*[@id="mp4"]') mp4.click() time.sleep(2) connected = False while not connected: try: search = self.browser.find_element_by_id('input') search.send_keys(self.video_url) time.sleep(2) button = self.browser.find_element_by_id('submit') button.click() connected = True except: time.sleep(2) connected = False while not connected: try: download = self.browser.find_element_by_link_text('Download') connected = True except: time.sleep(2) download.click() print('Downloading...') time.sleep(2) # Download time if self.browser_name == 'Firefox': word = ".part" else: word = ".crdownload" import os entries = os.listdir(self.file_path) while True: val = True for entry in entries: if word in entry: val = False time.sleep(2) if val: break entries = os.listdir(self.file_path) def close(self): print('Download Finished!') self.browser.quit()
while True: print( """Choose the browser you want to use:(Enter the appropriate number)\n 1---> firefox \n 2---> chrome \n 0--->exit""") choice = int(input()) if choice == 1: options = Options() options.headless = True driver = webdriver.Firefox(options=options) break elif choice == 2: options = webdriver.ChromeOptions() options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"]) options.add_argument('--disable-gpu') options.add_argument('--headless') driver = webdriver.Chrome(chrome_options=options) break elif choice == 0: quit() else: print("Please enter a valid choice") driver.get("https://medium.com/") driver.implicitly_wait(10) #action = webdriver.ActionChains(driver) time.sleep(2) login = driver.find_element_by_link_text('Sign in').click()
def _Get_Attenndence_Selenium(self): dir_path = os.path.dirname(os.path.realpath(__file__)) DIR_PATH = '/home/odoo/Downloads'+'/attlog.dat' # DIR_PATH = '/home/odoo/' list_id=[] list_name=[] list_date=[] list_time=[] for line in open(DIR_PATH, 'r'): item = line.rstrip() words=item.replace('\t', ' ') w_list = words.split(" ") count_name=0 count_id=0 count_id_id =0 count_date=0 count =0 for record in w_list: count = count + 1 if count == 1: list_id.append(record) if count == 2: list_name.append(record) if count == 3: list_date.append(record) if count == 4: list_time.append(record) index_id=0 for emp_id in list_id: print list_id[index_id] # raw_attendence=self.env['ecube.raw.attendance'].search([('machine_id','=',list_id[index_id]),('machine_date','=',list_date[index_id]),('machine_time','=',list_time[index_id])]) # if not raw_attendence: employee_id_raw =self.env['hr.employee'].search([('emp_machin_id','=',list_id[index_id])]) print employee_id_raw self.env['ecube.raw.attendance'].create({ 'employee_id': employee_id_raw.id, 'machine_id': list_id[index_id], 'machine_date': list_date[index_id], # 'machine_time': list_time[index_id], }) index_id = index_id +1 if "%s/attlog.dat" % DIR_PATH: os.remove(DIR_PATH) # zk = zklib.ZKLib(config.key['ip'], int(config.key['port'])) # res = zk.connect() display = Display(visible=0, size=(800, 600)) display.start() # profile = webdriver.FirefoxProfile() # profile.set_preference("browser.download.panel.shown", False) # profile.set_preference("browser.helperApps.neverAsk.openFile","text/csv,application/vnd.ms-excel") # profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/vnd.ms-excel,text/dat,text/plain") # profile.set_preference("browser.download.folderList", 2); # profile.set_preference("browser.download.dir", "/home/rocky/Downloads/") # chrome_options = Options() # chrome_options.add_argument("--headless") options = Options() options.add_experimental_option("prefs", { "download.default_directory": r"/home/odoo/Downloads", "download.prompt_for_download": False, "download.directory_upgrade": True, "safebrowsing.enabled": True }) # browser = webdriver.Firefox(executable_path="/home/rocky/Downloads/geckodriver") browser = webdriver.Chrome(executable_path="/home/odoo/Downloads/chromedriver") browser.wait = WebDriverWait(browser, 5) browser.get('http://37.99.147.178:4370') xpaths = { 'username' : "//input[@name='username']", 'passwd' : "//input[@name='userpwd']", 'login' : "//input[contains(@value,'Login')]", 'download' : "//input[contains(@value,'Download')]", 'search' : "//input[contains(@value,'Search')]", 'report' : "//a[text()='Report']" } print "Browser is opened" browser.find_element_by_xpath(xpaths['username']).clear() browser.find_element_by_xpath(xpaths['username']).send_keys('10403') time.sleep(5) print "username is typed" browser.find_element_by_xpath(xpaths['passwd']).clear() browser.find_element_by_xpath(xpaths['passwd']).send_keys('10403') time.sleep(5) print "password is typed" browser.find_element_by_xpath(xpaths['login']).click() browser.get('http://37.99.147.178:4370/csl/download') time.sleep(5) browser.find_element_by_xpath(xpaths['download']).click() # time.sleep(50) # browser.quit() print "browser Closed" # display.stop() # /home/odoo/phantomjs/home/odoo/phantomjs # Steps that required for this F*****G machine # Install https://github.com/dnaextrim/python_zklib this library # Install Selenium # Download Gekodriver # Export path of Geckodriver # Install sudo apt-get install xvfb #install sudo pip install pyvirtualdisplay
def get_browser_instance(self): try: if self.browser.lower() == "firefox": options = FirefoxOptions() if self.headless: options.add_argument("--headless") options.add_argument("-width=1920") options.add_argument("-height=1080") # options.add_argument("--disable-gpu") profile = webdriver.FirefoxProfile() # options.add_argument("--private") profile.accept_untrusted_certs = True service = Service(executable_path=GeckoDriverManager( cache_valid_range=10).install()) driver = webdriver.Firefox(service=service, firefox_profile=profile, options=options) elif self.browser.lower() == "chrome": options = ChromeOptions() if self.headless: options.add_argument('headless') options.add_argument('window-size=1920x1080') if self.mobile: mobile_emulation = {"deviceName": self.device} options.add_experimental_option("mobileEmulation", mobile_emulation) options.add_argument('ignore-certificate-errors') options.add_argument('--incognito') # options.add_argument('--start-maximized') options.add_experimental_option('useAutomationExtension', False) options.add_experimental_option("excludeSwitches", ["enable-automation"]) # options.add_experimental_option("excludeSwitches", ["enable-logging"]) options.add_argument('--log-level=3') service = Service( ChromeDriverManager(cache_valid_range=10).install()) driver = webdriver.Chrome(service=service, options=options) elif self.browser.lower() == "ie": driver = webdriver.Ie(IEDriverManager().install()) elif self.browser.lower() == "edge": options = EdgeOptions() if self.headless: options.add_argument('headless') options.add_argument('window-size=1920x1080') options.use_chromium = True options.add_argument('ignore-certificate-errors') options.add_experimental_option('useAutomationExtension', False) options.add_argument('--inprivate') options.add_argument('--log-level=3') options.add_experimental_option("excludeSwitches", ["enable-automation"]) service = Service( EdgeChromiumDriverManager(cache_valid_range=10, log_level=1).install()) driver = webdriver.Chrome(service=service, options=options) elif self.browser.lower() == 'browserstack': bs_local = Local() bs_local_args = { "key": key, "localIdentifier": localIdentifier } bs_local.start(**bs_local_args) driver = webdriver.Remote(command_executor=bb_url, desired_capabilities=browser_config) # elif self.browser.lower() =="docker": # options = FirefoxOptions() # options.add_argument("--headless") # options.add_argument("-width=1920") # options.add_argument("-height=1080") # profile = webdriver.FirefoxProfile() # # options.add_argument("--private") # profile.accept_untrusted_certs = True # driver = webdriver.Remote(command_executor="http://localhost:4444", options=options, browser_profile=profile) else: raise ValueError if self.headless: self.cl.info("Starting " + str(self.browser).upper() + " browser in headless mode") else: self.cl.info("Starting " + str(self.browser).upper() + " browser ") if self.browser.lower( ) == "browserstack" and 'browserName' in browser_config.keys(): pass else: driver.maximize_window() driver.delete_all_cookies() # driver.set_page_load_timeout(30) if self.baseUrl: driver.get(self.baseUrl) self.cl.info("Opening the URL :: " + str(self.baseUrl)) # driver.implicitly_wait(10) return driver except ValueError as val: self.cl.error( "Browser not supported :: " + str(self.browser) + ". Supported browser types are Chrome, Firefox, Edge. Exception occurred. :: " + str(val.__class__.__name__) + ' ' + str(val)) raise val except Exception as e: self.cl.error("Exception occurred. :: " + str(e.__class__.__name__) + ' ' + str(e)) raise e