mport time import json from selenium import webdriver from…
- User
mport time import json from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options
executable_path = 'C:\ChromeDriver\chromedriver.exe'
def create_chrome_driver(executable_path): service = Service(executable_path) options = Options()
# Установка требуемых опций браузера options.add_argument('--start-maximized') # Пример опции driver = webdriver.Chrome(service=service, options=options) return driver#executable_path = '/путь/к/драйверу/chromedriver.exe'
def save_page_html(driver, url, file_name): driver.get(url) time.sleep(10) # Дайте странице время для загрузки и рендеринга
# Извлечение актуального HTML-кода с помощью Chrome DevTools Protocol performance_log = driver.get_log('performance') events = [json.loads(entry['message'])['message'] for entry in performance_log] html = '' for event in events: if 'method' in event and event['method'] == 'Network.responseReceived': response = event['params']['response'] if response['mimeType'] == 'text/html': response_url = response['url'] if response_url == url: request_id = event['params']['requestId'] html_response = driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': request_id}) html = html_response['body'] break driver.quit() with open(file_name, 'w', encoding="utf-8") as file: file.write(html)start = time.time() driver = create_chrome_driver(executable_path)
save_page_html(driver, 'https://www.playscores.com/scanner-futebol-online/ao-vivo', 'rendered_page.html') end = time.time() - start
print(end) Этот код выдает ошибку Message: invalid argument: log type 'performance' not found (Session info: chrome=115.0.5790.102) Stacktrace: Backtrace: GetHandleVerifier [0x00007FF6DABA3E62+57250] (No symbol) [0x00007FF6DAB1BC02] (No symbol) [0x00007FF6DA9EE0BB] (No symbol) [0x00007FF6DAA5414C] (No symbol) [0x00007FF6DAA46770] (No symbol) [0x00007FF6DAA1CC71] (No symbol) [0x00007FF6DAA1DE54] GetHandleVerifier [0x00007FF6DAE54CF2+2879026] GetHandleVerifier [0x00007FF6DAEA6F30+3215472] GetHandleVerifier [0x00007FF6DAE9FD4F+3186319] GetHandleVerifier [0x00007FF6DAC35505+652869] (No symbol) [0x00007FF6DAB27518] (No symbol) [0x00007FF6DAB235F4] (No symbol) [0x00007FF6DAB236EC] (No symbol) [0x00007FF6DAB138E3] BaseThreadInitThunk [0x00007FFF7FAB7614+20] RtlUserThreadStart [0x00007FFF810826F1+33] File "C:\Users\MP\Documents\MP_sandbox\WZPV4", line 29, in save_page_html performance_log = driver.get_log('performance') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\MP\Documents\MP_sandbox\WZPV4", line 52, in save_page_html(driver, 'https://www.playscores.com/scanner-futebol-online/ao-vivo', 'rendered_page.html') selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: log type 'performance' not found (Session info: chrome=115.0.5790.102) Stacktrace: Backtrace: GetHandleVerifier [0x00007FF6DABA3E62+57250] (No symbol) [0x00007FF6DAB1BC02] (No symbol) [0x00007FF6DA9EE0BB] (No symbol) [0x00007FF6DAA5414C] (No symbol) [0x00007FF6DAA46770] (No symbol) [0x00007FF6DAA1CC71] (No symbol) [0x00007FF6DAA1DE54] GetHandleVerifier [0x00007FF6DAE54CF2+2879026] GetHandleVerifier [0x00007FF6DAEA6F30+3215472] GetHandleVerifier [0x00007FF6DAE9FD4F+3186319] GetHandleVerifier [0x00007FF6DAC35505+652869] (No symbol) [0x00007FF6DAB27518] (No symbol) [0x00007FF6DAB235F4] (No symbol) [0x00007FF6DAB236EC] (No symbol) [0x00007FF6DAB138E3] BaseThreadInitThunk [0x00007FFF7FAB7614+20] RtlUserThreadStart [0x00007FFF810826F1+33]
- Assistant
The error message suggests that the 'performance' log type is not found in the Chrome browser. This error can occur if the Chrome browser version you are using does not support the 'performance' log type or if there is an issue with the ChromeDriver.
To resolve this issue, you can try the following steps:
-
Update Chrome and ChromeDriver: Make sure you are using the latest versions of Chrome and ChromeDriver. You can check the Chrome version by going to chrome://version in the Chrome browser. Download the latest version of ChromeDriver from the official website () and replace the existing ChromeDriver with the new one.
-
- User
Можешь ответить по русски?
- Assistant
Конечно! Прошу прощения за предыдущий ответ на английском. Вот переведенные инструкции:
Сообщение об ошибке говорит о том, что тип журнала 'performance' не найден в браузере Chrome. Это может произойти, если используемая вами версия Chrome не поддерживает тип журнала 'performance' или если возникла проблема с ChromeDriver.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.