'Disabling cookie messages with selenium python
I searched for a bit before, but I didn't find an answer for this question. I am dealing with basically all websites out there and I'm parsing all the text. Mostly everything is fine except the fact that some sites have about as much actual text as they have cookie accept text. I am wondering if its possible to completely disable the "accept cookies" message banner from even appearing. I have tried:
caps['browser_api_name'] = 'Chrome39'
caps['os_api_name'] = 'WinXPSP2-C2'
caps['screen_resolution'] = '1024×768'
caps['record_video'] = 'true'
caps['record_network'] = 'false'
caps['record_snapshot'] = 'false'
caps['chromeOptions'] = { "prefs" : { "profile.default_content_settings.cookies" : 2 } }
and
chrome_options.add_experimental_option("prefs", {"profile.default_content_setting_values.cookies": 1})
for example I am using selenium in python with chrome webdriver
This is my code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
url = 'https://www.digi24.ro/bacalaureat-2021/frauda-la-bacalaureat-in-5-judete-subiectele-la-proba-scrisa-au-aparut-pe-internet-la-cateva-minute-de-la-inceperea-examenului-1637707'
chrome_options = Options()
chrome_options.add_experimental_option("prefs", {"profile.default_content_setting_values.cookies": 1})
# chrome_options.add_argument("--headless")
# chrome_options.add_argument("--window-size=1920,1080")
driver = webdriver.Chrome('test_shit/chromedriver', chrome_options=chrome_options)
driver.set_page_load_timeout(10)
driver.get(url)
time.sleep(10)
driver.close()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
