selenium_stealth
时间: 2023-12-06 15:38:41 浏览: 46
selenium_stealth是一个Python包,可以帮助您在使用Selenium时更隐身。它支持Selenium Chrome / Chromium,并且可以防止几乎所有的Selenium检测。以下是一个使用selenium_stealth的示例代码:
```python
from selenium import webdriver
from selenium_stealth import stealth
# 创建一个Chrome浏览器实例
driver = webdriver.Chrome()
# 使用Selenium Stealth设置
stealth(driver, languages=["en-US", "en"], vendor="Google Inc.", platform="Win32", webgl_vendor="Intel Inc.", renderer="Intel Iris OpenGL Engine", fix_hairline=True, )
# 打开一个网页
driver.get("https://bot.sannysoft.com/")
```
在上面的代码中,我们首先导入了webdriver和stealth模块。然后,我们创建了一个Chrome浏览器实例,并使用stealth函数将其设置为隐身模式。最后,我们打开了一个网页。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![js](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)