Pyinstaller 抑制 "DeprecationWarning" Python
Pyinstaller suppress "DeprecationWarning" Python
我得到
start.py:146: DeprecationWarning: firefox_profile has been deprecated, please use an Options object
start.py:163: DeprecationWarning: firefox_profile has been deprecated, please pass in an Options object
selenium\webdriver\remote\webdriver.py:483: UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
selenium\webdriver\remote\webdriver.py:723: UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
当我编译我的 .py 时,我想找到一种方法来抑制它。我查看了其他线程,但它们似乎都不起作用。
编辑更多代码:
profile = webdriver.FirefoxProfile(profile)
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options)
用于修复错误 UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
你可以使用下面的方法
from selenium.webdriver.common.by import By
然后像这样使用
driver.find_element(By.XPATH, '//input[@id='search']')
错误 Firefox DeprecationWarning:
profile = webdriver.FirefoxProfile(profile)
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
gecko_path = "path_to_geckodriver\geckodriver.exe"
path = "path_to_firefoxs\Mozilla Firefox\firefox.exe"
binary = FirefoxBinary(path)
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options, executable_path=gecko_path)
此外,您可以像这样直接添加您的 firefox 配置文件
profile = webdriver.FirefoxProfile('C:/Users/x/AppData/Roaming/Mozilla/Firefox/Profiles/some-long-string')
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
gecko_path = "path_to_geckodriver\geckodriver.exe"
path = "path_to_firefoxs\Mozilla Firefox\firefox.exe"
binary = FirefoxBinary(path)
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options, executable_path=gecko_path)
我得到
start.py:146: DeprecationWarning: firefox_profile has been deprecated, please use an Options object
start.py:163: DeprecationWarning: firefox_profile has been deprecated, please pass in an Options object
selenium\webdriver\remote\webdriver.py:483: UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
selenium\webdriver\remote\webdriver.py:723: UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
当我编译我的 .py 时,我想找到一种方法来抑制它。我查看了其他线程,但它们似乎都不起作用。
编辑更多代码:
profile = webdriver.FirefoxProfile(profile)
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options)
用于修复错误 UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
你可以使用下面的方法
from selenium.webdriver.common.by import By
然后像这样使用
driver.find_element(By.XPATH, '//input[@id='search']')
错误 Firefox DeprecationWarning:
profile = webdriver.FirefoxProfile(profile)
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
gecko_path = "path_to_geckodriver\geckodriver.exe"
path = "path_to_firefoxs\Mozilla Firefox\firefox.exe"
binary = FirefoxBinary(path)
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options, executable_path=gecko_path)
此外,您可以像这样直接添加您的 firefox 配置文件
profile = webdriver.FirefoxProfile('C:/Users/x/AppData/Roaming/Mozilla/Firefox/Profiles/some-long-string')
profile.set_preference("dom.webdriver.enabled", False)
profile.set_preference('useAutomationExtension', False)
profile.update_preferences()
gecko_path = "path_to_geckodriver\geckodriver.exe"
path = "path_to_firefoxs\Mozilla Firefox\firefox.exe"
binary = FirefoxBinary(path)
options = FirefoxOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15')
options.add_argument('--disable-plugins-discovery')
options.add_argument('referer=https://www.youtube.com/')
options.add_argument('--disable-extensions')
options.add_argument('--profile-directory=Default')
options.add_argument('--disable-blink-featuresi=AutomationControlled')
options.add_argument('--disable-blink-features')
driver = webdriver.Firefox(firefox_profile=profile, options=options, executable_path=gecko_path)