示例#1
0
def json_to_file():
    if (app.driver == None):
        undetected_chromedriver.install()
        dir_name, file_name = os.path.split(os.path.abspath(__file__))
        print(dir_name, file_name)
        chromeOptions = webdriver.ChromeOptions()
        prefs = {"download.default_directory" : os.path.join(dir_name, 'output')}
        chromeOptions.add_experimental_option("excludeSwitches", ['enable-automation']);
        chromeOptions.add_experimental_option("prefs",prefs)
        chromeOptions.add_argument("user-data-dir=selenium1")
        #chromeOptions.add_argument("--incognito")
        chromedriver = "chromedriver.exe"
        app.driver = webdriver.Chrome(chrome_options=chromeOptions)
    #Write the input file to JSON
    data = json.loads(request.data)
    dir_name, file_name = os.path.split(os.path.abspath(__file__))
    json_input_path = os.path.join(dir_name, 'input.json')
    with open(json_input_path, 'w') as outfile:
        json.dump(data, outfile)
    
    #json_input_path = the file where json is written
    #json_file_path = "E:\\UpWork\\2020\\April\\Crunch Base JSON to CSV\\input.json"

    output_json, app.driver = process(app.driver, json_input_path)
    
    return output_json
示例#2
0
def webdriver_complete(visivel: bool):

    undetected_chromedriver.install()  # baixando o chromedriver indetectavel.

    option = webdriver.ChromeOptions()

    if visivel == False:
        option.add_argument('--headless')

    driver = webdriver.Chrome(executable_path='./chromedriver.exe',
                              chrome_options=option)

    return driver
示例#3
0
def chromeInit():
    uc.TARGET_VERSION = 85
    uc.install()

    from selenium.webdriver import Chrome
    from selenium.webdriver import Chrome, ChromeOptions

    opts = ChromeOptions()
    opts.add_argument('--no-sandbox')
    opts.add_argument('--disable-dev-shm-usage')
    opts.headless = False

    driver = Chrome(options=opts)
    return driver
示例#4
0
def webdriver_complete(visible: bool):
    sistema = platform.system()
    undetected_chromedriver.install()

    if sistema == 'Linux':
        path = os.getcwd() + barra() + 'chromedriver'
    else:
        path = os.getcwd() + barra() + 'chromedriver.exe'

    options = webdriver.ChromeOptions()
    if visible == False:

        options.add_argument("--headless")
    options.add_argument('ignore-certificate-errors')
    options.add_argument('--no-sandbox')

    driver = webdriver.Chrome(executable_path=path, chrome_options=options)
    return driver
        'HKEY_CURRENT_USER\\Software\\Google\\Chrome\\BLBeacon', '/v',
        'version'
    ],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.DEVNULL,
                               stdin=subprocess.DEVNULL)
    version = process.communicate()[0].decode('UTF-8').strip().split()[-1]
else:
    print('{} OS is not supported.'.format(OSNAME))
    sys.exit()

major_version = version.split('.')[0]

uc.TARGET_VERSION = major_version

uc.install()


def type_me(element, text):
    """
    Type like a human
    """
    for letter in text:
        element.send_keys(letter)
        sleep(uniform(.1, .3))


for proxy in proxy_config.proxy:

    proxy_split = proxy.split(":")
    PROXY_HOST = proxy_split[0]
示例#6
0
            authCredentials: {
                username: "******",
                password: "******"
            }
        };
    }

    chrome.webRequest.onAuthRequired.addListener(
                callbackFn,
                {urls: ["<all_urls>"]},
                ['blocking']
    );
    """ % (PROXY_HOST, PROXY_PORT, PROXY_USER, PROXY_PASS)
    
    uc.install(
        executable_path='chromedriver.exe',
    )
    options = uc.ChromeOptions()
    pluginfile = 'proxy_auth_plugin.zip'
    with zipfile.ZipFile(pluginfile, 'w') as zp:
        zp.writestr("manifest.json", manifest_json)
        zp.writestr("background.js", background_js)
    options.add_extension(pluginfile)
    prefs = {"profile.default_content_setting_values.notifications" : 2}
    options.add_experimental_option("prefs",prefs)
    options.add_experimental_option('prefs', {
        'credentials_enable_service': False,
        'profile': {
            'password_manager_enabled': False
        }
    })
示例#7
0
"""
    https://github.com/ultrafunkamsterdam/undetected-chromedriver#important-note
"""
# import undetected_chromedriver as uc
# options = uc.ChromeOptions()
# # options.headless=True
# # options.add_argument('--headless')
# chrome = uc.Chrome(options=options)
# chrome.get("https://www.facebook.com/")
# # chrome.save_screenshot('datadome_undetected_webddriver.png')



import undetected_chromedriver as uc

#specify chromedriver version to download and patch
uc.TARGET_VERSION = 86 

# or specify your own chromedriver binary (why you would need this, i don't know)

uc.install(
    executable_path='/home/xuananh/Downloads/chromedriver',
)

opts = uc.ChromeOptions()
driver = uc.Chrome(options=opts, enable_console_log=True)
driver.get("https://www.facebook.com/")

示例#8
0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import os
import pandas as pd

#specify chromedriver version to download and patch
import undetected_chromedriver as uc

uc.TARGET_VERSION = 87

# or specify your own chromedriver binary (why you would need this, i don't know)

uc.install(executable_path='/home/tiago/Desktop/chromedriver/chromedriver', )

opts = uc.ChromeOptions()
driver = uc.Chrome(options=opts)

stocks_to_search = [
    "Nike", "Johnson&Johnson", "ExxonMobil", "Petrobras", "Ambev", "Adidas",
    "Heineken"
]
currency_chosen = "EUR"

company_name = []
stock_value = []
currency = []
average_in_points = []
average_in_percentage = []
stock_code = []
stock_location = []