import json from selenium import webdriver import pandas as pd # Before crawl: Initialize the ChromeDriver with the profile options = webdriver.ChromeOptions() options.add_argument("--user-data-dir=./profile_dir") driver = webdriver.Chrome(options=options) # Here is your crawler's logic driver.get('https://google.com') # example # After crawl: # Extract the crawled data EXTENSION_ID = 'fbhiolckidkciamgcobkokpelckgnnol' # replace with your ID identified in step 3. # Load extension settings driver.get(f'chrome-extension://{EXTENSION_ID}/options/cookieblock_options.html') # Extraction script indexeddb_script = """ function getCookieBlockHistory() { return new Promise((resolve, reject) => { var request = window.indexedDB.open("CookieBlockHistory", 1); request.onerror = function(event) { reject("Error opening IndexedDB: " + event.target.errorCode); }; request.onsuccess = function(event) { var db = event.target.result; var transaction = db.transaction(["cookies"], "readonly"); var objectStore = transaction.objectStore("cookies"); var data = []; objectStore.openCursor().onsuccess = function(event) { var cursor = event.target.result; if (cursor) { data.push(cursor.value); cursor.continue(); } }; transaction.oncomplete = function() { resolve(JSON.stringify(data)); }; transaction.onerror = function(event) { reject("Transaction error: " + event.target.errorCode); }; }; }); } return getCookieBlockHistory().then(data => { return data; }).catch(error => { return error; }); """ indexeddb_data = driver.execute_script(indexeddb_script) try: cookies = json.loads(indexeddb_data) except TypeError as e: print("Error:", e) cookies = [] df = pd.DataFrame(cookies) df.to_csv('./cookies.csv', index=False)