-
Notifications
You must be signed in to change notification settings - Fork 542
Expand file tree
/
Copy pathtest_webdriver.py
More file actions
45 lines (36 loc) · 1011 Bytes
/
test_webdriver.py
File metadata and controls
45 lines (36 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
Created on 2021/3/18 7:05 下午
---------
@summary:
---------
@author: Boris
@email: boris_liu@foxmail.com
"""
from feapder.utils.webdriver import WebDriverPool, WebDriver
import threading
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()
def test_webdriver():
with WebDriver(
load_images=True, driver_type=WebDriver.CHROME, timeout=30
) as browser:
browser.get("https://httpbin.org/get")
html = browser.page_source
print(html)
print(browser.user_agent)
import time
time.sleep(1000)
test_webdriver()