比特浏览器bit_selenium3bit_selenium4使用

bit_selenium3

比特浏览器bit_selenium3bit_selenium4使用_第1张图片

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from bit_api import *

# /browser/open 接口会返回 selenium使用的http地址,以及webdriver的path,直接使用即可
res = openBrowser()
driverPath = res['data']['driver']
debuggerAddress = res['data']['http']

print(driverPath)
print(debuggerAddress)

chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", debuggerAddress)
driver = webdriver.Chrome(driverPath, options=chrome_options)
driver.get('https://www.baidu.com/')

bit_selenium4

比特浏览器bit_selenium3bit_selenium4使用_第2张图片

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from bit_api import *
from selenium.webdriver.chrome.service import Service

# /browser/open 接口会返回 selenium使用的http地址,以及webdriver的path,直接使用即可
res = openBrowser()
driverPath = res['data']['driver']
debuggerAddress = res['data']['http']

print(driverPath)
print(debuggerAddress)


# 创建一个自定义的 Service 对象
service = Service(executable_path=driverPath)

chrome_options = Options()
chrome_options.debugger_address = debuggerAddress

# slenium4之后版本不能在这里直接通过executable_path定义driverPath
driver = webdriver.Chrome(service=service,options=chrome_options)  
driver.get('https://www.baidu.com/')

用上selenium4以后,感觉重器也变轻了~

civilpy:Python数据分析及可视化实例目录939 赞同 · 36 评论文章​编辑

你可能感兴趣的:(07_其他总结,python)