python类Firefox()的实例源码

adidasREQ.py 文件源码 项目:OpenCouture-Dev 作者: 9-9-0 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def inspectCart2(self):
        print '\nINSPECT CART ----------------'
        self.get_headers['Accept-Encoding'] = 'gzip, deflate, sdch, br'
        self.get_headers['Referer'] = self.URL_product_url
        session_get = self.user_session.get(url=self.URL_cart_url, headers=self.get_headers)

        print 'Inspect Cart Status: ' + str(session_get.status_code)

        cookies = self.user_session.cookies.get_dict()
        with open('injectCookies', 'wb') as output:
            output.write(json.dumps(cookies, indent=1))

        driver = webdriver.Firefox()
        driver.get(self.URL_cart_url)
        driver.add_cookie(cookies)
        driver.get(self.URL_cart_url)
browser.py 文件源码 项目:biweeklybudget 作者: jantman 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def chrome(self):
        # https://github.com/SeleniumHQ/selenium/blob/master/py/selenium/webdriver/remote/webdriver.py
        # http://www.guguncube.com/2983/python-testing-selenium-with-google-chrome
        # https://gist.github.com/addyosmani/5336747
        # http://blog.likewise.org/2015/01/setting-up-chromedriver-and-the-selenium-webdriver-python-bindings-on-ubuntu-14-dot-04/
        # https://sites.google.com/a/chromium.org/chromedriver/getting-started
        # http://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium
        chrome = webdriver.Chrome()
        return chrome

#     @property
#     def firefox(self):
#         profile = webdriver.FirefoxProfile()
#         #firefox = webdriver.Firefox(firefox_profile=profile)
#         firefox = WebDriver(firefox_profile=profile)
#         return firefox
download facebook photos.py 文件源码 项目:Facebook-Photos-Download-Bot 作者: NalinG 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def main(username, account_password,destination):
    profile = webdriver.FirefoxProfile()
    profile.set_preference('browser.download.folderList', 2) # custom location
    profile.set_preference('browser.download.manager.showWhenStarting', False)
    profile.set_preference('browser.download.dir', destination)
    profile.set_preference('browser.helperApps.neverAsk.saveToDisk', "image/png,image/jpeg")

    if not username == "NONE" and not account_password == "NONE" and not destination == "NONE":
        display = Display(visible=0, size=(800, 600))
            display.start()
        driver = webdriver.Firefox(firefox_profile=profile)
        driver.get("https://www.facebook.com")

        email_id = driver.find_element_by_id("email")
        password = driver.find_element_by_id("pass")
        email_id.send_keys(username)
        password.send_keys(account_password)
        driver.find_element_by_id("loginbutton").click()
        # driver.find_element_by_css_selector("._5afe.sortableItem").click()
        driver.find_element_by_id("navItem_2305272732").click()
        time.sleep(3)
        list_of_images = driver.find_elements_by_css_selector(".uiMediaThumbImg")
        list_of_images[0].click()
        # print list_of_images
        for image in list_of_images:
            time.sleep(3)
            driver.find_element_by_xpath("//div[@class = 'overlayBarButtons rfloat _ohf']/div/div/a").click()
            time.sleep(3)
            option = driver.find_element_by_xpath("//div[@class = 'uiContextualLayerPositioner uiLayer']/div/div/div[@class = '_54ng']/ul[@class = '_54nf']/li[4]/a")
            option_name = option.find_element_by_xpath(".//*")
            option_name = option_name.find_element_by_xpath(".//*")
            if option_name.get_attribute('innerHTML').lower() == "download":
                option_name.click()
            # print option.get_attribute('innerHTML')
            driver.find_element_by_css_selector(".snowliftPager.next.hilightPager").click()

            display.stop()

    else:
        print "\nIncomplete Parameters, Program is Shutting Down."
WebRunner.py 文件源码 项目:PyWebRunner 作者: IntuitiveWebSolutions 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_js_errors(self):
        '''
        Uses the JSErrorCollector plugin for Chrome / Firefox to get any JS errors.

        [
            {
                'sourceName': u'tests/html/js_error.html',
                'pageUrl': u'tests/html/js_error.html',
                'errorMessage': 'ReferenceError: b is not defined',
                'lineNumber': 7
            }
        ]
        '''
        if self.driver in ('Chrome', 'Firefox'):
            return self.js('return window.JSErrorCollector_errors ? window.JSErrorCollector_errors.pump() : []')
        else:
            print("Checking for JS errors with this method only works in Firefox or Chrome")
            return []
autoLikeAndrei.py 文件源码 项目:PythonStudyCode 作者: TongTongX 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def login():
    driver = webdriver.Firefox()

    driver.implicitly_wait(10)

    driver.get("https://www.facebook.com")
    driver.find_element_by_id('email').send_keys("email_address")
    driver.find_element_by_id('pass').send_keys("password")
    driver.find_element_by_id('u_0_n').click()

    '''
    time.sleep(1)
    print "------- login ---------"
    email = driver.find_element_by_id('email')
    email.send_keys("email_address")
    time.sleep(1)
    password = driver.find_element_by_id('pass')
    password.send_keys("password")
    time.sleep(1)
    password.send_keys(Keys.RETURN)
    time.sleep(2)
    driver.get("https://www.facebook.com")
    time.sleep(1)
    pickle.dump(driver.get_cookies(), open("cookies.pkl", "w"))
    '''
browser_mgmt.py 文件源码 项目:warriorframework 作者: warriorframework 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def set_firefoxprofile(proxy_ip, proxy_port):
        """method to update the given preferences in Firefox profile"""
        ff_profile = webdriver.FirefoxProfile()
        if proxy_ip is not None and proxy_port is not None:
            proxy_port = int(proxy_port)
            ff_profile.set_preference("network.proxy.type", 1)
            ff_profile.set_preference("network.proxy.http", proxy_ip)
            ff_profile.set_preference("network.proxy.http_port", proxy_port)
            ff_profile.set_preference("network.proxy.ssl", proxy_ip)
            ff_profile.set_preference("network.proxy.ssl_port", proxy_port)
            ff_profile.set_preference("network.proxy.ftp", proxy_ip)
            ff_profile.set_preference("network.proxy.ftp_port", proxy_port)
            ff_profile.update_preferences()
        else:
            ff_profile = None
        return ff_profile

    # private methods
browser_mgmt.py 文件源码 项目:warriorframework 作者: warriorframework 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _make_ff(self, webdriver_remote_url, desired_capabilites, profile_dir,
                 binary, gecko_path):
        """Create an instance of firefox browser"""
        try:
            if webdriver_remote_url:
                browser = self._create_remote_web_driver(
                        webdriver.DesiredCapabilities.FIREFOX,
                        webdriver_remote_url, desired_capabilites,
                        profile_dir)
            else:
                ff_capabilities = webdriver.DesiredCapabilities.FIREFOX
                if ff_capabilities['marionette']:
                    ff_capabilities['acceptInsecureCerts'] = True
                    ffbinary = FirefoxBinary(binary)
                    browser = webdriver.Firefox(firefox_binary=ffbinary,
                                                firefox_profile=profile_dir,
                                                executable_path=gecko_path)
                else:
                    browser = webdriver.Firefox(firefox_profile=profile_dir)
            return browser
        except WebDriverException as e:
            if "executable needs to be in PATH" in str(e):
                print_error("Please provide path for geckodriver executable")
            elif "Expected browser binary location" in str(e):
                print_error("Please provide path of firefox executable")
test_webdriver.py 文件源码 项目:core-python 作者: yidao620c 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def click_page():
    driver = webdriver.Firefox()
    driver.get('http://yidao620c.github.io/archives/')
    driver.maximize_window()
    len1 = len(driver.find_elements_by_xpath(
                '//div[@class="post-archive"]/ul[@class="listing"]/li/a'))
    _log.info('????????...')
    for k in range(1, 100):
        logging.info('?{}???...'.format(k))
        for i in range(0, len1):
            l_xpath = '(//div[@class="post-archive"]/ul[@class="listing"]/li/a)[{}]'.format(i + 1)
            ele = WebDriverWait(driver, 2).until(
                EC.presence_of_element_located((By.XPATH, l_xpath))
            )
            ele.click()
            driver.back()

    _log.info('all finished.')
    driver.close()
selenium_helpers_base.py 文件源码 项目:isar 作者: ilbers 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def create_selenium_driver(browser='chrome'):
    # set default browser string based on env (if available)
    env_browser = os.environ.get('TOASTER_TESTS_BROWSER')
    if env_browser:
        browser = env_browser

    if browser == 'chrome':
        return webdriver.Chrome(
            service_args=["--verbose", "--log-path=selenium.log"]
        )
    elif browser == 'firefox':
        return webdriver.Firefox()
    elif browser == 'marionette':
        capabilities = DesiredCapabilities.FIREFOX
        capabilities['marionette'] = True
        return webdriver.Firefox(capabilities=capabilities)
    elif browser == 'ie':
        return webdriver.Ie()
    elif browser == 'phantomjs':
        return webdriver.PhantomJS()
    else:
        msg = 'Selenium driver for browser %s is not available' % browser
        raise RuntimeError(msg)
harvest_utils.py 文件源码 项目:DLink_Harvester 作者: MikimotoH 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def getFirefox(tempDir='/tmp', showImage=1):
    """get Firefox Webdriver object
    :param showImage: 2 = don't show, 1=show
    """
    proxy = Proxy(dict(proxyType=ProxyType.AUTODETECT))
    profile = webdriver.FirefoxProfile()
    profile.set_preference("plugin.state.flash", 0)
    profile.set_preference("plugin.state.java", 0)
    profile.set_preference("media.autoplay.enabled", False)
    # 2=dont_show, 1=normal
    profile.set_preference("permissions.default.image", showImage)
    profile.set_preference("webdriver.load.strategy", "unstable")
    # automatic download
    # 2 indicates a custom (see: browser.download.dir) folder.
    profile.set_preference("browser.download.folderList", 2)
    # whether or not to show the Downloads window when a download begins.
    profile.set_preference("browser.download.manager.showWhenStarting", False)
    profile.set_preference("browser.download.dir", tempDir)
    profile.set_preference("browser.helperApps.neverAsk.saveToDisk",
                           "application/octet-stream"+
                           ",application/zip"+
                           ",application/x-rar-compressed"+
                           ",application/x-gzip"+
                           ",application/msword")
    return webdriver.Firefox(firefox_profile=profile, proxy=proxy)
tests.py 文件源码 项目:Django-Web-Development-with-Python 作者: PacktPublishing 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def setUpClass(cls):
        super(LiveLocationTest, cls).setUpClass()
        cls.browser = webdriver.Firefox()
        cls.browser.delete_all_cookies()
        cls.location = Location.objects.create(
            title="Haus der Kulturen der Welt",
            slug="hkw",
            small_image="locations/2015/11/20151116013056_small.jpg",
            medium_image="locations/2015/11/20151116013056_medium.jpg",
            large_image="locations/2015/11/20151116013056_large.jpg",
        )
        cls.username = "test-admin"
        cls.password = "test-admin"
        cls.superuser = User.objects.create_superuser(
            username=cls.username,
            password=cls.password,
            email="",
        )
drivers.py 文件源码 项目:cabu 作者: thylong 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def load_driver(config, vdisplay=None):
    """Initialize a weddriver selected in config with given config.

    Args:
        config (dict): The configuration loaded previously in Cabu.

    Returns:
        webdriver (selenium.webdriver): An instance of selenium webdriver or None.
    """

    if config['DRIVER_NAME'] == 'Firefox':
        driver = load_firefox(config)
    elif config['DRIVER_NAME'] == 'Chrome':
        driver = load_chrome(config)
    elif config['DRIVER_NAME'] == 'PhantomJS':
        driver = load_phantomjs(config)
    elif not config.get('DRIVER_NAME'):
        return None
    else:
        raise DriverException(vdisplay, 'Driver unrecognized.')

    driver.set_page_load_timeout(config['DRIVER_PAGE_TIMEOUT'])
    driver.set_window_size(config['DRIVER_WINDOWS_WIDTH'], config['DRIVER_WINDOWS_HEIGHT'])

    return driver
scraper.py 文件源码 项目:voamos 作者: miguelsc 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def init_driver(self):
        global driver

        if self.is_initialized:
            return

        if self.driver_name == 'chrome':
            driver = webdriver.Chrome(executable_path=self.driver_path)
        elif self.driver_name == 'phantomjs':
            driver = webdriver.PhantomJS(executable_path=self.driver_path)
        elif self.driver_name == 'firefox':
            driver = webdriver.Firefox(executable_path=self.driver_path)
        else:
            raise Exception(
                'Driver "{}" is not supported'.format(self.driver_name))

        self.is_initialized = True
        driver.set_window_size(self.width, self.height)
        driver.implicitly_wait(5)
middleware.py 文件源码 项目:EasyCrawler 作者: playwolf719 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def process_request(self, request, spider):
        try:
            driver = webdriver.PhantomJS() #????????
             # driver = webdriver.Firefox()
            print "---"+str(request.meta["page"])+"-----js url start-------"
            print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            driver.get(self.pc_index_url+"&page="+str(request.meta["page"]) )
            # time.sleep(1)
            tmp=driver.find_element_by_id('sf-item-list-data').get_attribute("innerHTML")
            print "---"+str(request.meta["page"])+"-----js url end-------"
            print datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            body = tmp
            return HtmlResponse(driver.current_url, body=body, encoding='utf-8', request=request)
        except Exception,e:
            print "-------------------"
            print e.__doc__
            print e.message
            print "-------------------"
utils.py 文件源码 项目:automation-design-patterns 作者: paulbodean88 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_selenium_driver(browser_name: str) -> Union[Chrome, Firefox]:
    """
    Return the same instance to the Selenium driver.

    :param browser_name: the name of the browser: chrome or mozilla
    :type browser_name: str
    :return: an instance of the required driver.
    :rtype: Union[Chrome, Mozilla]
    """
    if browser_name.upper() == 'CHROME':
        return SingletonFactory.build(Chrome)

    elif browser_name.upper() == 'Mozilla':
        return SingletonFactory.build(Firefox)

    else:
        raise NotImplementedError
get_html.py 文件源码 项目:taobao 作者: chifeng111 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_page(key_words):
    html = []
    b = webdriver.PhantomJS(executable_path="phantomjs.exe")
    #b = webdriver.Firefox()
    b.get("https://world.taobao.com/")
    time.sleep(3)
    b.find_element_by_id('q').send_keys(key_words)
    b.find_element_by_xpath('/html/body/div[1]/div[2]/div/div/div/div[2]/div[1]/div[2]/form/div[1]/button').click()
    time.sleep(3)
    b.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    b.maximize_window()
    html.append(b.page_source.encode('gbk', 'ignore'))
    for i in range(99):
        b.find_element_by_xpath('/html/body/div[5]/div[4]/div/div[1]/div[1]/div[4]/div/div/a[last()]/span').click()
        page = str(i+1)
        time.sleep(5)
        b.execute_script("window.scrollTo(0, document.body.scrollHeight);")
        html.append(b.page_source.encode('gbk', 'ignore'))
        print("?????%s?" %page)
    b.close()
    return html

#/html/body/div[5]/div[4]/div/div[1]/div[1]/div[4]/div/div/a[last()]/span
#/html/body/div[5]/div[4]/div/div[1]/div[1]/div[4]/div/div/a[7]/span
DIY_JSParser.py 文件源码 项目:Hanhan_NLP 作者: hanhanwu 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def main():
    comment_urls = [
        "http://www.theglobeandmail.com/opinion/a-fascists-win-americas-moral-loss/article32753320/comments/"
                   ]

    for comment_url in comment_urls:
        driver = webdriver.Firefox()
        driver.get(comment_url)
        time.sleep(5)
        htmlSource = driver.page_source
        clk = driver.find_element_by_css_selector('div.c3qHyJD')
        clk.click()
        reaction_counts = driver.find_elements_by_class_name('c2oytXt')
        for rc in reaction_counts:
            print(rc.text)
        driver.close()   # close the browser
Robot.py 文件源码 项目:AmazonRobot 作者: WuLC 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, proxy):
        """init the webdriver by setting the proxy and user-agent

        Args:
            proxy (str): proxy in the form of ip:port
        """
        # set proxy
        ip, port = proxy.split(':')
        profile = webdriver.FirefoxProfile()
        profile.set_preference("network.proxy.type", 1)
        profile.set_preference("network.proxy.http", ip)
        profile.set_preference("network.proxy.http_port", port)
        # set user_agent
        profile.set_preference("general.useragent.override", generate_user_agent())

        profile.update_preferences()
        self.driver = webdriver.Firefox(firefox_profile=profile)

        print 'current proxy: %s'%proxy
test-ui.py 文件源码 项目:nextcloud 作者: syncloud 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def driver():

    if exists(screenshot_dir):
        shutil.rmtree(screenshot_dir)
    os.mkdir(screenshot_dir)

    firefox_path = '{0}/firefox/firefox'.format(DIR)
    caps = DesiredCapabilities.FIREFOX
    caps["marionette"] = True
    caps['acceptSslCerts'] = True

    binary = FirefoxBinary(firefox_path)

    profile = webdriver.FirefoxProfile()
    profile.add_extension('{0}/JSErrorCollector.xpi'.format(DIR))
    profile.set_preference('app.update.auto', False)
    profile.set_preference('app.update.enabled', False)
    driver = webdriver.Firefox(profile,
                               capabilities=caps, log_path="{0}/firefox.log".format(LOG_DIR),
                               firefox_binary=binary, executable_path=join(DIR, 'geckodriver/geckodriver'))
    # driver.set_page_load_timeout(30)
    # print driver.capabilities['version']
    return driver
dk.py 文件源码 项目:kungahusgranskning 作者: jplusplus 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def scrape_until(self, year):
        """ Scrape all calender events from today until a given year.
            Returns data as a list of dicts.
        """
        self.driver = webdriver.Firefox()
        self.start_url = "http://kongehuset.dk/menu/kalender"

        # Get a list of all persons
        self._open_calendar()

        data = []
        current_date = self.get_current_year_and_month()
        while current_date["year"] > year:
            print ("Parse %s, %s" % (current_date["month"], current_date["year"]))
            month_data = self._parse_calender()
            data += month_data
            sleep(1)
            self._go_to_previous_month()
            current_date = self.get_current_year_and_month()

        self.data = data
        return data
pyEbaySniper.py 文件源码 项目:pyEbaySniper 作者: braph 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def setup_vars():
    reg_variable('USER',     'User for ebay')
    reg_variable('PASSWORD', 'Password for ebay')
    reg_variable('DRIVER',   'Driver to use with selenium', 'PhantomJS',
        validate=lambda v: v in ('Chrome', 'Firefox', 'PhantomJS')
    )
    reg_variable('LOCALE',   'Localization for numerics and monetary stuff',
        validate=lambda v: locale.setlocale(locale.LC_ALL, v)
    )
    reg_variable('BID_AHEAD_SECONDS', 'How many seconds before the actually specified time the bid should be placed',
        value=3, type=int
    )
    reg_variable('HISTORY',   'History file',
        os.path.expanduser("~/.ebay_hist")
    )
    #reg_variable('COOKIE_FILE', 'File for cookies. (Optional)',
    #    os.path.expandvars('/tmp/ebay-$USER-cookie')
    #)

    reg_variable('DEBUG', 'Print stacktraces and write ghostdriver.log', type=bool, value=0)
    reg_variable('LOGIN_URL', 'URL for ebay login page', 'https://signin.ebay.de/ws/eBayISAPI.dll?SignIn')
    reg_variable('LOGIN_URL_RE', 'RegEx to check if URL is a login page', 'https://signin.ebay.de')
    reg_variable('LOGIN_FIELD_PASS_RE', 'RegEx to find password input field in login page', 'passwor')
    reg_variable('LOGIN_FIELD_USER_RE', 'RegEx to find user input field in login page', 'e-mail')
launcher.py 文件源码 项目:kibitzr 作者: kibitzr 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def firefox(headless=True):
    """
    Context manager returning Selenium webdriver.
    Instance is reused and must be cleaned up on exit.
    """
    from selenium import webdriver
    from selenium.webdriver.firefox.options import Options
    if headless:
        driver_key = 'headless'
        firefox_options = Options()
        firefox_options.add_argument('-headless')
    else:
        driver_key = 'headed'
        firefox_options = None
    # Load profile, if it exists:
    if os.path.isdir(PROFILE_DIR):
        firefox_profile = webdriver.FirefoxProfile(PROFILE_DIR)
    else:
        firefox_profile = None
    if FIREFOX_INSTANCE[driver_key] is None:
        FIREFOX_INSTANCE[driver_key] = webdriver.Firefox(
            firefox_profile=firefox_profile,
            firefox_options=firefox_options,
        )
    yield FIREFOX_INSTANCE[driver_key]
albertheijn.py 文件源码 项目:albert-heijn-calendar-sync 作者: StefanPahlplatz 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self):
        """
        Initializes a web client and logs the user in.
        """
        with open('settings.yaml') as s:
            settings = yaml.load(s)
        print('Initializing web driver...')
        if settings['showbrowser']:
            self.driver = webdriver.Firefox(executable_path=settings['geckopath'])
        else:
            if settings['phantomjspath']:
                self.driver = webdriver.PhantomJS(executable_path=settings['phantomjspath'])
            else:
                self.driver = webdriver.PhantomJS()
        print('Logging in...')
        self.__login()
        print('Loading the schedule...')
        self.__load_schedule()
test_user_management.py 文件源码 项目:picoCTF 作者: picoCTF 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setup_class(self):
        start_xvfb()
        self.driver = webdriver.Firefox()
        self.test_user = register_test_user(self.driver)
test_problem_workflow.py 文件源码 项目:picoCTF 作者: picoCTF 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def setup_class(self):
        start_xvfb()
        self.driver = webdriver.Firefox()
        self.test_user = register_test_user(self.driver)
adidasREQ.py 文件源码 项目:OpenCouture-Dev 作者: 9-9-0 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def finalBossSEL(self):
        driver = webdriver.Firefox()
        driver.get(self.URL_pay_url)
        driver.add_cookie(self.user_session.cookies)
bodegaMECH.py 文件源码 项目:OpenCouture-Dev 作者: 9-9-0 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        self.br = mechanize.Browser()
        #self.cj = cookielib.LWPCookieJar()
        self.cj = cookielib.MozillaCookieJar()

        self.br.set_cookiejar(self.cj)
        self.br.set_handle_equiv(True)
        self.br.set_handle_referer(True)
        self.br.set_handle_robots(False)
        self.br.addheaders = [('User-agent', 'Firefox')]

        self.item_url = 'http://shop.bdgastore.com/collections/footwear/products/y-3-pureboost-zg'

        # Create variables for user credentials and a function to import them
bodegaMECH.py 文件源码 项目:OpenCouture-Dev 作者: 9-9-0 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def checkCart(self):
        print self.cj

        #driver = webdriver.Firefox()
        #driver.add_cookie(cj_dict)
        #driver.get('http://shop.bdgastore.com/cart')
        #print(driver.get_cookies())
        #for cookie in self.cj:
        #    print cookie.name, cookie.value, cookie.domain
        #try importing cookies manually vs using the requests util

        #driver = webdriver.Chrome('./chromedriver')
dorknet.py 文件源码 项目:DorkNet 作者: NullArray 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def proxy(PROXY_HOST,PROXY_PORT):
    fp = webdriver.FirefoxProfile()
    print "[" + t.green("+") + "]Proxy host set to: " + PROXY_HOST
    print "[" + t.green("+") + "]Proxy port set to: " + PROXY_PORT
    print "\n[" + t.green("+") + "]Establishing connection..."
    fp.set_preference("network.proxy.type", 1)
    fp.set_preference("network.proxy.http",PROXY_HOST)
    fp.set_preference("network.proxy.http_port",int(PROXY_PORT))
    fp.set_preference("general.useragent.override","'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36'")
    fp.update_preferences()
    return webdriver.Firefox(firefox_profile=fp)


# Function to generate and process results based on input
cb_spider.py 文件源码 项目:NewsScrapy 作者: yinzishao 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self):
        self.display = Display(visible=0, size=(800, 600))  #???????
        self.display.start()
        # self.chromedriver = "/home/youmi/Downloads/chromedriver"
        # self.driver = webdriver.Chrome(self.chromedriver)              #??display???????
        chromedriver = "/home/ubuntu/geckodriver"
        self.driver = webdriver.Firefox(executable_path=chromedriver)


问题


面经


文章

微信
公众号

扫码关注公众号