Ejemplo n.º 1
0
def test_webdirver_pool():

    webdriver_pool = WebDriverPool(
        pool_size=2, load_images=False, driver_type=WebDriver.FIREFOX, timeout=30
    )

    def request():
        try:
            browser = webdriver_pool.get()
            browser.get("https://baidu.com")
            print(browser.title)
            webdriver_pool.put(browser)
        except:
            print("失败")

    for i in range(5):
        threading.Thread(target=request).start()
Ejemplo n.º 2
0
    def _webdriver_pool(self):
        if not self.__class__.webdriver_pool:
            self.__class__.webdriver_pool = WebDriverPool(**setting.WEBDRIVER)

        return self.__class__.webdriver_pool
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
"""
Created on 2021/3/18 7:05 下午
---------
@summary:
---------
@author: Boris
@email: [email protected]
"""
from feapder.utils.webdriver import WebDriverPool, WebDriver
import threading

webdriver_pool = WebDriverPool(pool_size=2,
                               load_images=False,
                               driver_type=WebDriver.CHROME,
                               timeout=30)


def request():
    try:
        browser = webdriver_pool.get()
        browser.get("https://news.qq.com/")
        html = browser.page_source
        print(html[:100])
        webdriver_pool.remove(browser)
    except:
        print("失败")

    # with WebDriver(
    #     load_images=False, driver_type=WebDriver.CHROME, timeout=30
    # ) as browser: