【发布时间】:2021-09-06 13:39:59
【问题描述】:
嘿社区我正在关注来自 freecodecamp 的硒教程,我正在使用 Facebook 进行测试我正在使用 MacBook 我使用 brew 安装了我的 chromedriver
我遇到了第一个警报问题,我想禁用警报,但不知道如何将其添加到我的 chrome,因为它在没有声明驱动程序路径的情况下自行打开,请帮助所有答案显示正在声明的路径和使用 chrome 选项禁用它,但我是从 Webdriver.Chrome 继承的
import facebook.constants as const
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
class FacebookBot(webdriver.Chrome):
"""a class to control and automate a facebook bot for srappping"""
def __init__(self, teardown=False):
self.teardown = teardown
super(FacebookBot, self).__init__()
self.implicitly_wait(20)
def __exit__(self, *args) -> None:
if self.teardown:
self.quit()
return super().__exit__(*args)
def facebook_homepage(self):
"""navigating the facebook scrapper bot to the facebook home page."""
self.get(const.BASE_URL)```
【问题讨论】:
标签: python-3.x selenium selenium-webdriver web-scraping chrome-web-driver