selenium常用设置与函数

最近在学习使用selenium,踩了很多坑,主要集中在导入Options报错,版本如下:

Python 3.11.5

Name: selenium
Version: 4.11.2
Summary:
Home-page: https://www.selenium.dev
Author:
Author-email:
License: Apache 2.0
Location: C:\Python311\Lib\site-packages
Requires: certifi, trio, trio-websocket, urllib3
Required-by: selenium-wire

分享和记录现在能用的设置:

from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
from selenium.common.exceptions import NoSuchElementException


hide_windown = 0 #0不隐藏,1隐藏
    
options = Options()
if hide_windown == 1:
    options.add_argument('--headless') #增加无界面选项
    options.page_load_strategy = 'normal'#等待加载图片normal eager none 
else:
    options.page_load_strategy = 'eager'#不等待加载图片normal eager none
opt
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值