コード例 #1
0
def check(domain_name):
    """Categorize site with all proxies in proxies folder."""
    # Submit domain to proxies via apis
    for k, v in get_check_api_proxies().items():
        resp = v(domain_name)
        print(f"{k} responded with {resp}")

    # Submit domain to proxies via selenium
    for k, v in get_check_proxies().items():
        options = webdriver.ChromeOptions()
        options.add_argument("start-maximized")
        try:
            driver = uc.Chrome(
                executable_path=f"{script_dir}/drivers/chromedriver",
                options=options,
            )
        except OSError:
            driver = uc.Chrome(
                executable_path=f"{script_dir}/drivers/chromedriver.exe",
                options=options,
            )
        try:
            resp = v(driver, domain_name)
            print(f"{k} responded with {resp}")
            time.sleep(3)
        except Exception as e:
            print(str(e))
        finally:
            driver.quit()
コード例 #2
0
def corporate_actions():
    '''
    The wrapper function which utilizes all other functions and utilizes them to download files.

    NOTE: I have noticed the best time to download the file is from 10AM - 5PM, after that BSE
    Website starts getting unresponsive and the code is unable to download .csv files because of no 
    response from BSE. Please keep that in mind while scheduling scrips and see what works best for you.
    '''
    bse_corp_path = 'https://www.bseindia.com/corporates/corporate_act.aspx'

    default_downloads_path = join('C:', os.sep, 'Users', os.getlogin(),
                                  'Downloads')

    driver = uc.Chrome()
    driver.get(bse_corp_path)
    download_corp_action(driver, 'dividend')
    time.sleep(15)
    latest_file = get_latest_file(default_downloads_path)
    rename_latest_file(latest_file, f'{default_downloads_path}/dividend.csv')

    download_corp_action(driver, 'split')
    time.sleep(5)
    latest_file = get_latest_file(default_downloads_path)
    rename_latest_file(latest_file, f'{default_downloads_path}/split.csv')

    download_corp_action(driver, 'bonus')
    time.sleep(5)
    latest_file = get_latest_file(default_downloads_path)
    rename_latest_file(latest_file, f'{default_downloads_path}/bonus.csv')

    driver.close()
コード例 #3
0
 def from_crawler(cls, crawler):
     # This method is used by Scrapy to create your spiders.
     s = cls()
     s.cookie = ""
     if sys.platform == "linux" or sys.platform == "linux2":
         s.display = Display(visible=0, size=(800, 600))
         s.display.start()
         logging.info("Virtual Display Initiated")
     chrome_options = Options()
     if crawler.spider.undetectable:
         s.driver = uc.Chrome()
     else:
         driver_location = "/usr/bin/chromedriver"
         #driver_location = which('chromedriver')
         # binary_location = "/usr/bin/google-chrome"
         userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.56 Safari/537.36"
         # chrome_options.binary_location = binary_location
         chrome_options.add_argument(f'user-agent={userAgent}')
         chrome_options.add_argument("--ignore-certificate-errors")
         chrome_options.add_argument("--ignore-ssl-errors")
         chrome_options.add_argument("--headless" )
         # chrome_options.addArguments("--no-sandbox");
         #chrome_options.addArguments("--disable-dev-shm-usage")
         s.driver = webdriver.Chrome(executable_path="/home/knust/allen/igroup/coupons/chromedriver",chrome_options=chrome_options)  # your chosen driver
     crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
     crawler.signals.connect(s.spider_closed, signal=signals.spider_closed)
     return s
コード例 #4
0
 def get_driver(self):
     option = webdriver.ChromeOptions()
     option.set_capability('unhandledPromptBehavior', 'accept')
     option.add_argument('high-dpi-support=1')
     option.add_argument('device-scale-factor=1')
     option.add_argument('force-device-scale-factor=1')
     option.add_argument(
         "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36")
     option.add_argument('window-size=%d,%d' % self.res)
     option.add_argument('headless')
     # self.driver = webdriver.Chrome(chrome_options=option)
     self.driver = uc.Chrome(options=option)
     self.driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
         "source": """
           Object.defineProperty(navigator, 'webdriver', {
             get: () => false
           })
           window.navigator.chrome = undefined;
           Object.defineProperty(navigator, 'languages', {
             get: () => ['en-US', 'en'],
           });
           Object.defineProperty(navigator, 'plugins', {
             get: () => [1, 2, 3, 4, 5],
           });
           const originalQuery = window.navigator.permissions.query;
           window.navigator.permissions.query = (parameters) => (
             parameters.name === 'notifications' ?
             Promise.resolve({ state: Notification.permission }) :
             originalQuery(parameters)
           );
         """
     })
コード例 #5
0
    def __init__(self, driver_name, driver_executable_path,
                 browser_executable_path, command_executor, driver_arguments):
        """Initialize the selenium webdriver

        Parameters
        ----------
        driver_name: str
            The selenium ``WebDriver`` to use
        driver_executable_path: str
            The path of the executable binary of the driver
        driver_arguments: list
            A list of arguments to initialize the driver
        browser_executable_path: str
            The path of the executable binary of the browser
        command_executor: str
            Selenium remote server endpoint
        """
        if driver_name == 'uc':
            # uses https://github.com/ultrafunkamsterdam/undetected-chromedriver to bypass blocking
            options = uc.ChromeOptions()
            for argument in driver_arguments:
                options.add_argument(argument)
            self.driver = uc.Chrome(options=options)
        else:
            webdriver_base_path = f'selenium.webdriver.{driver_name}'

            driver_klass_module = import_module(
                f'{webdriver_base_path}.webdriver')
            driver_klass = getattr(driver_klass_module, 'WebDriver')

            driver_options_module = import_module(
                f'{webdriver_base_path}.options')
            driver_options_klass = getattr(driver_options_module, 'Options')

            driver_options = driver_options_klass()

            if browser_executable_path:
                driver_options.binary_location = browser_executable_path
            for argument in driver_arguments:
                driver_options.add_argument(argument)

            driver_kwargs = {
                'executable_path': driver_executable_path,
                'options': driver_options
            }

            # locally installed driver
            if driver_executable_path is not None:
                driver_kwargs = {
                    'executable_path': driver_executable_path,
                    'options': driver_options
                }
                self.driver = driver_klass(**driver_kwargs)
            # remote driver
            elif command_executor is not None:
                from selenium import webdriver
                capabilities = driver_options.to_capabilities()
                self.driver = webdriver.Remote(
                    command_executor=command_executor,
                    desired_capabilities=capabilities)
コード例 #6
0
    def get_fandom_name(url: str) -> str:
        """Scrape browse page url and return fandom name.

        Args:
            url (str): url of fandom browse page
                       ex: https://www.fanfiction.net/book/Harry-Potter/

        Returns:
            str: scraped fandom name

        """

        options = uc.ChromeOptions()
        options.headless = True
        options.add_argument('--headless')
        chrome = uc.Chrome(options=options)

        chrome.get(url)
        html = chrome.page_source
        soup = BeautifulSoup(html, "lxml")

        regex = r" (FanFiction Archive|Crossover) \| FanFiction$"
        name = re.sub(regex, '', soup.find('title').string)

        time.sleep(5)
        chrome.quit()
        return name
コード例 #7
0
def check_registration():
    running = True
    options = Options()
    options.add_argument("start-maximized")
    options.headless = True

    while running:
        driver = uc.Chrome(options=options)
        # Set useragent to googlebot
        # driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'})
        driver.get("https://vini.nh.gov/providers/s/")
        e = WebDriverWait(driver, 15).until(
            EC.presence_of_element_located(
                (By.XPATH, "//*[contains(text(),'years old or older.')]")))
        now = localtime()

        if e.text != "I am 30 years old or older.":
            print(e.text)
            notify()
            running = False
            print(
                f'SITE HAS UPDATED: {now.tm_mon}/{now.tm_mday} {now.tm_hour}:{now.tm_min}:{now.tm_sec}'
            )
        else:
            print(
                f'No changes as of {now.tm_mon}/{now.tm_mday} {now.tm_hour}:{now.tm_min} Trying again...'
            )
            sleep(30)
        driver.quit()
コード例 #8
0
def check_for_update():
    BASE_URL = "https://www.amazon.co.uk/s?k=1440p+144hz+monitor&i=computers&rh=n%3A428652031%2Cp_n_specials_match%3A21583550031"

    options = uc.ChromeOptions()
    options.headless = True
    options.add_argument('--headless')
    chrome = uc.Chrome(options=options)
    chrome.get(BASE_URL)
    html = chrome.page_source

    soup = BeautifulSoup(html, features='lxml')

    results_html = soup.find_all(
        attrs={"data-component-type": "s-search-results"})[0].select(
            ".s-main-slot")[0].findChildren(
                attrs={"data-component-type": "s-search-result"},
                recursive=False)

    titles = list(
        map(lambda res: res.find(attrs={
            "class": "a-size-medium"
        }).get_text(), results_html))
    titles.sort()

    title_str = ''.join(titles)

    with open('results_cache.txt', "r") as f:
        if f.read() != title_str:
            send_notification()
            print("Sending notification")

    with open('results_cache.txt', 'w') as f:
        f.write(title_str)
コード例 #9
0
ファイル: OZCTN1.py プロジェクト: Puppet00/puppet
def get_cookie(url):
    global useragent, cookieJAR, cookie
    options = webdriver.ChromeOptions()
    arguments = [
    '--no-sandbox', '--disable-setuid-sandbox', '--disable-infobars', '--disable-logging', '--disable-login-animations',
    '--disable-notifications', '--disable-gpu', '--headless', '--lang=ko_KR', '--start-maxmized',
    '--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60 MicroMessenger/6.5.18 NetType/WIFI Language/en' 
    ]
    for argument in arguments:
        options.add_argument(argument)
    driver = webdriver.Chrome(options=options)
    driver.implicitly_wait(3)
    driver.get(url)
    for _ in range(60):
        cookies = driver.get_cookies()
        tryy = 0
        for i in cookies:
            if i['name'] == 'cf_clearance':
                cookieJAR = driver.get_cookies()[tryy]
                useragent = driver.execute_script("return navigator.userAgent")
                cookie = f"{cookieJAR['name']}={cookieJAR['value']}"
                driver.quit()
                return True
            else:
                tryy += 1
                pass
        time.sleep(1)
    driver.quit()
    return False
コード例 #10
0
def yandex(phone_number):
    global name
    global yandex_load_balancer
    yandex_load_balancer=True
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('disable-infobars')
    options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
    options.add_argument("user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36")
    loc=os.getcwd()
    driver = uc.Chrome(options=options)
    driver.get("https://passport.yandex.com/auth/add")
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.NAME, "login"))).send_keys(phone_number)
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '/html/body/div/div/div/div[2]/div/div/div[2]/div[3]/div/div/div/div[1]/form/div[3]/button'))).click()

    #/html/body/div[1]/div[3]/div[1]/div/div/form/div/div[2]/ul/li[1]/div/table/tbody/tr/td[1]/div/div/div/div[2]/div[1]
    try:

        WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.NAME, 'passwd'))).click()

        name="This Phone Number Is Connected To A Yandex Account!"
        print(colored.green("[+]")+colored.blue(name))
       

    except:
        name="This Phone Number Is Not Connected To Any Yandex Account!"
        print(colored.magenta("[-]")+colored.red(name))
    yandex_load_balancer=False
    driver.quit()
コード例 #11
0
def login_in_zerodha(api_key, api_secret, user_id, user_pwd, totp_key):
    driver = uc.Chrome()
    driver.get(f'https://kite.trade/connect/login?api_key={api_key}&v=3')
    login_id = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_xpath('//*[@id="userid"]'))
    login_id.send_keys(user_id)

    pwd = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_xpath('//*[@id="password"]'))
    pwd.send_keys(user_pwd)

    submit = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_xpath('//*[@id="container"]/div/div/div[2]/form/div[4]/button'))
    submit.click()

    time.sleep(1)

    totp = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_xpath('//*[@id="totp"]'))
    authkey = pyotp.TOTP(totp_key)
    totp.send_keys(authkey.now())

    continue_btn = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_xpath('//*[@id="container"]/div/div/div[2]/form/div[3]/button'))
    continue_btn.click()

    time.sleep(5)

    url = driver.current_url
    initial_token = url.split('request_token=')[1]
    request_token = initial_token.split('&')[0]
    
    driver.close()
    
    kite = KiteConnect(api_key = api_key)
    #print(request_token)
    data = kite.generate_session(request_token, api_secret=api_secret)
    kite.set_access_token(data['access_token'])
    
    return kite
コード例 #12
0
def r_level(phone_number):

    global name
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('disable-infobars')
    options.add_experimental_option('prefs',
                                    {'intl.accept_languages': 'en,en_US'})
    options.add_argument(
        "user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
    )
    loc = os.getcwd()
    driver = uc.Chrome(options=options)
    driver.get("https://spamcalls.net/en")

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable(
        (By.NAME, "q"))).send_keys(phone_number)

    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable(
            (By.XPATH,
             '/html/body/div[2]/div/div/div/div[1]/form/button'))).click()
    name = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.CLASS_NAME, 'typ'))).text

    if "Other" in name or "other" in name:
        name = "Spam Potensial: High Risk/SPAM"

    print(colored.blue(name))
コード例 #13
0
def selenium_get_url(url, delay=0, nopic=False, uc=False):
    chrome_options = Options()
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--disable-dev-shm-usage')
    
    if nopic:
        prefs = {'profile.managed_default_content_settings.images': 2}
        chrome_options.add_experimental_option('prefs', prefs)
        
    if uc:
        browser = undetected_chromedriver.Chrome()
    else:
        browser = webdriver.Chrome(options=chrome_options)
        
    try:
        browser.get(url)
        if delay != 0:
            time.sleep(delay)
        html = browser.page_source
    except:
        print(GET_PAGE_SOURCE_ERROR_MSG)
        pass
    finally:
        browser.close()
        
    return BeautifulSoup(html, 'lxml')
コード例 #14
0
def deep_one(phone_number):
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('disable-infobars')
    options.add_experimental_option('prefs',
                                    {'intl.accept_languages': 'en,en_US'})
    options.add_argument(
        "user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
    )
    loc = os.getcwd()
    driver = uc.Chrome(options=options)
    driver.get("https://www.duckduckgo.com/")
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable(
            (By.XPATH, "/html/body/div/div[2]/div/div[1]/div[2]/form/input[1]"
             ))).send_keys(phone_number)
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((
            By.XPATH,
            '/html/body/div/div[2]/div/div[1]/div[2]/form/input[2]'))).click()
    try:
        for x in range(0, 30):
            xpath = '//*[@id="r1-%s"]/div/div[1]/div/a' % x
            name = WebDriverWait(driver, 10).until(
                EC.element_to_be_clickable((By.XPATH, xpath))).text
            print(colored.green(
                "[+]This Link Could Be Relevant With Your Number:"),
                  end="")
            print(colored.blue(name))
    except:
        pass
コード例 #15
0
def tw(phone_number):
    global name
    global twitter_load_balancer
    twitter_load_balancer = True
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('disable-infobars')
    options.add_experimental_option('prefs',
                                    {'intl.accept_languages': 'en,en_US'})
    options.add_argument(
        "user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
    )
    loc = os.getcwd()
    driver = uc.Chrome(options=options)
    driver.get("https://twitter.com/login/")
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable(
            (By.NAME, "session[username_or_email]"))).send_keys(phone_number)
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable(
            (By.NAME, "session[password]"
             ))).send_keys("ihopeitsnotyourpasswordtygodtyjesus")
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((
            By.XPATH,
            '//*[@id="react-root"]/div/div/div[2]/main/div/div/div[1]/form/div/div[3]/div'
        ))).click()

    #/html/body/div[1]/div[3]/div[1]/div/div/form/div/div[2]/ul/li[1]/div/table/tbody/tr/td[1]/div/div/div/div[2]/div[1]
    try:
        time.sleep(5)
        try:
            name = WebDriverWait(driver, 10).until(
                EC.element_to_be_clickable((
                    By.XPATH,
                    '//*[@id="react-root"]/div/div/div[2]/main/div/div/div[1]/span'
                ))).text
        except:
            #/html/body/div/div/div/div[2]/main/div/div/div[1]/span
            name = WebDriverWait(driver, 10).until(
                EC.element_to_be_clickable(
                    (By.XPATH,
                     '/html/body/div/div/div/div[2]/main/div/div/div[1]/span'
                     ))).text
        if name == "The phone number and password you entered did not match our records. Please double-check and try again.":
            name = "This Phone Number Is Not Connected To Any Twitter Account!"
            print(colored.magenta("[-]") + colored.red(name))

        else:
            name = "This Phone Number Is Connected To A Twitter Account!"
            print(colored.green("[+]") + colored.blue(name))

        driver.close()
    except:
        pass

    twitter_load_balancer = False
コード例 #16
0
def init_game():
    chrome_options = Options()
    chrome_options.add_argument('--window-size=1920,1080')
    chrome_options.add_argument('--start-maximized')
    d = uc.Chrome(options=chrome_options)
    d.get('https://www.chess.com/play/computer')
    util.remove_popup(d)
    game = chess.Board()
    return d, game
コード例 #17
0
def fb(phone_number):
    global name
    global facebook_load_balancer
    facebook_load_balancer = True
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('disable-infobars')
    options.add_experimental_option('prefs',
                                    {'intl.accept_languages': 'en,en_US'})
    options.add_argument(
        "user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
    )
    loc = os.getcwd()
    driver = uc.Chrome(options=options)
    driver.get("https://www.facebook.com/login/identify")
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((
            By.XPATH,
            "/html/body/div[1]/div[3]/div[1]/div/div/div/form/div/div[2]/div/table/tbody/tr[2]/td[2]/input"
        ))).send_keys(phone_number)
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((
            By.XPATH,
            "/html/body/div[1]/div[3]/div[1]/div/div/div/form/div/div[3]/div/div[1]/label/input"
        ))).click()
    #/html/body/div[1]/div[3]/div[1]/div/div/form/div/div[2]/ul/li[1]/div/table/tbody/tr/td[1]/div/div/div/div[2]/div[1]
    try:
        name = WebDriverWait(driver, 10).until(
            EC.element_to_be_clickable((
                By.XPATH,
                "/html/body/div[1]/div[3]/div[1]/div/div/form/div/div[2]/ul/li[1]/div/table/tbody/tr/td[1]/div/div/div/div[2]/div[1]"
            ))).text
        print(
            colored.green(
                "[+]This Phone Number Is Connected To A Facebook Account!"))
        name = "Connected To A Facebook Account.Facebook Name/Number:" + str(
            name)
    except:
        #fsl fwb fcb
        try:
            name = WebDriverWait(driver, 10).until(
                EC.element_to_be_clickable((
                    By.XPATH,
                    '//*[@id="initiate_interstitial"]/div[1]/table/tbody/tr/td[2]/div/div/div[2]/div'
                ))).text

            name = "This Phone Number Is Connected To A Facebook Account. Facebook Name/Number:" + str(
                name)

        except:
            name = "This Phone Number Is Not Connected To Any Facebook Account!"

    print(name)
    driver.quit()
    facebook_load_balancer = False
コード例 #18
0
 def __init__(self):
     # prepare WebDriver
     self.options = uc.ChromeOptions()
     self.options.headless = False
     self.options.add_argument(
         '/Users/vincentyan/Library/Application Support/Google/Chrome')
     self.options.add_argument(
         'user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"'
     )
     self.driver = uc.Chrome(options=self.options)
コード例 #19
0
def head_uc(request: FixtureRequest):
    request.instance.driver = uc.Chrome()

    def teardown():
        request.instance.driver.save_screenshot(FAILED_SCREENSHOT_NAME)
        request.instance.driver.quit()

    request.addfinalizer(teardown)

    return request.instance.driver
コード例 #20
0
 def __init__(self):
     if Browser.__instance is not None:
         raise Exception("This class is a singleton!")
     else:
         Browser.__instance = self
     self.user_agent = ""
     options = uc.ChromeOptions()
     self.browser = uc.Chrome(options=options)
     self.cookie = Cookies.getCookies(self)
     self._setUserAgent()
コード例 #21
0
 def get_new_marionette(cls, headless: bool = False) -> uc.Chrome:
     print('Requesting a new marionette')
     options = uc.ChromeOptions()
     if headless:
         options.headless = True
         options.add_argument('--headless')
     options.add_argument('--disable-gpu')
     options.add_argument('--no-first-run --no-service-autorun --password-store=basic')
     driver = uc.Chrome(options=options)
     print('Got new marionette.')
     return driver
コード例 #22
0
def headless_uc(request: FixtureRequest):
    options = uc.ChromeOptions()
    options.headless = True
    request.instance.driver = uc.Chrome(options=options)

    def teardown():
        request.instance.driver.sapipve_screenshot(FAILED_SCREENSHOT_NAME)
        request.instance.driver.quit()

    request.addfinalizer(teardown)

    return request.instance.driver
コード例 #23
0
    def __init__(self, proxy=False, headless=False):
        self.options = uc.ChromeOptions()
        if headless:
            self.options.headless = True
            self.options.add_argument('--headless')

        if proxy:
            self.set_proxy()

        self.driver = uc.Chrome(options=self.options)
        self.logger = logging.getLogger(__name__)
        self.driver.implicitly_wait(0)
コード例 #24
0
def categorization_manager(domain_url, category_name):
    """Categorize site with all proxies in proxies folder."""
    # Submit domain to proxy
    for k, v in get_categorize_proxies().items():
        try:
            driver = webdriver.Chrome(
                executable_path=f"{script_dir}/drivers/chromedriver")
        except OSError:
            driver = webdriver.Chrome(
                executable_path=f"{script_dir}/drivers/chromedriver.exe")

        try:
            v(driver, domain_url, category_name, api_key)
            time.sleep(3)
        except Exception as e:
            print(str(e))
        finally:
            driver.quit()

    # Quit WebDriver
    print(f"{domain_url} has been categorized")
コード例 #25
0
 def __init__(self, **kwargs):
     super().__init__()
     option = uc.ChromeOptions()
     # option.add_argument('--headless')
     with open(self.custom_settings['cookie_dir'], 'r',
               encoding='utf-8') as f:
         cookie = json.loads(f.read())
     option.add_argument("--start-maximized")
     self.browser = uc.Chrome(options=option)
     self.browser.get(self.start_urls)
     # load cookies
     for cookie_ in cookie:
         self.browser.add_cookie(cookie_dict=cookie_)
コード例 #26
0
def inst(phone_number):
    global name
    global instagram_load_balancer
    instagram_load_balancer = True
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    options.add_argument('--no-sandbox')
    options.add_argument('disable-infobars')
    options.add_experimental_option('prefs',
                                    {'intl.accept_languages': 'en,en_US'})
    options.add_argument(
        "user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
    )
    loc = os.getcwd()
    driver = uc.Chrome(options=options)
    driver.get("https://www.instagram.com/")
    WebDriverWait(driver,
                  10).until(EC.element_to_be_clickable(
                      (By.NAME, "username"))).send_keys(phone_number)
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable(
            (By.NAME,
             "password"))).send_keys("thiswill123notbeyourpasswordihope")
    #/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div[4]/button
    WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable(
            (By.XPATH,
             '//*[@id="loginForm"]/div[1]/div[3]/button/div'))).click()
    try:
        name = WebDriverWait(driver, 10).until(
            EC.element_to_be_clickable((By.ID, "slfErrorAlert"))).text
        if name == "Sorry, your password was incorrect. Please double-check your password.":
            name = "This Phone Number Is Connected To An Instagram Account!"
            print(colored.green("[+]") + colored.blue(name))
            with open("output/social_media_results.txt", "a+") as file:
                file.write(
                    "This Phone Number Is Connected To An Instagram Account!\n"
                )

        else:
            name = "This Phone Number Is Not Connected To Any Instagram Account!"
            print(colored.magenta("[-]") + colored.red(name))
            with open("output/social_media_results.txt", "a+") as file:
                file.write(
                    "This Phone Number Is Not Connected To Any Instagram Account!\n"
                )

    except:
        pass
    instagram_load_balancer = False
    driver.close()
コード例 #27
0
ファイル: brokers.py プロジェクト: twhi/stockdash
    def initialise_selenium(self):
        caps = DesiredCapabilities.CHROME
        chrome_options = Options()

        if self.suppress_logs:
            chrome_options.add_argument("--log-level=3")

        if self.headless:
            chrome_options.add_argument('--headless')

        d = uc.Chrome(options=chrome_options, desired_capabilities=caps)

        # d = webdriver.Chrome(options=chrome_options, desired_capabilities=caps)
        return d
コード例 #28
0
ファイル: browser.py プロジェクト: directedbyshawn/Spotlight
    def start(self):

        #ensures that browser is not already open before opening
        if (self.is_browser_open()):
            raise BrowserNotOpenError
        else:

            #initiates web browser
            self.driver = uc.Chrome()

            #sets browser status to true, indicating that the browser is active
            self.__set_browser_status(True)

            print(self.__browser_status)
コード例 #29
0
def WebController(url):
    global driver
    global scan_active
    global current_state
    global thread_stop
    try:
        options = uc.ChromeOptions()
        options.add_argument('--headless')
        driver = uc.Chrome(options=options)
        #driver = uc.Chrome('C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe', options=options)
        driver.get("https://www.twitch.tv/popout/"+str(poll)+"/poll")
        scan_active = True
    except:
        current_state = "Webdriver Error"
コード例 #30
0
def WebController(url):
    global driver
    global scan_active
    global current_state
    global thread_stop
    try:
        options = uc.ChromeOptions()
        driver = uc.Chrome(options=options)
        #options.add_argument('--headless')
        #driver = uc.Chrome('C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe', options=options)
        driver.get(url)
        scan_active = True
    except:
        current_state = "Webdriver Error"