Solved Message: unknown error: cannot connect to chrome at 127.0.0.1:9222

已解决Message: unknown error: cannot connect to chrome at 127.0.0.1:9222
from session not created: This version of ChromeDriver only supports Chrome version 108
Current browser version is 113.0.5672.93









Error report



A small partner in the VIP full-stack answering group of thousands of people came to private message me when he encountered a problem, and wanted to use selenium to operate the browser, but an error occurred (at that time, his heart was cold for a moment, and he came to me for help, and then it went smoothly. Help him solve it, and record it by the way, hoping to help more friends who encounter this bug and will not solve it), the error code is as follows:

from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

def get_html_str(url):
    chrome_options = Options()
    chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")  # 通过端口号接管已打开的浏览器
    driver = webdriver.Chrome(options=chrome_options)
    # driver.maximize_window()
    driver.get(url)
    html_str = driver.page_source
    return html_str

A screenshot of the content of the error message is as follows :


insert image description here



error translation



The translation of the error message content is as follows :

Message: Unknown error: Unable to connect to chrome at 127.0.0.1:9222

From session not created: This version of ChromeDriver only supports Chrome version 108

The current browser version is 113.0.5672.93



Error reason



Reason for error :

An error is reported because the driver version of the operating browser is different from the browser version.

Friends, follow the method below to solve it permanently! ! !



Solution

1. Download the corresponding driver version



1. Check the browser version:
insert image description here

2. Download the corresponding Chrome driver version : http://chromedriver.storage.googleapis.com/index.html


insert image description here

3. Select the window version:


insert image description here


4. After decompressing the installation package, .exeput the driver into the Python installation path :


insert image description here

5. Start the program again successfully:


insert image description here

2. Set to permanently prohibit automatic upgrade of Google Chrome

Step 1: Turn off the update service


1. Keyboard windows logo key + R key, enter services.msc, and then confirm

insert image description here

2. Find two Google update services, double-click to open


insert image description here

3. In the properties interface that pops up, click Stop first, then set the startup type to Disable, then select Apply and OK:

insert image description here

4. Check whether both updates are disabled:


insert image description here

Step 2: Turn off update permissions

Chrome updates are upgraded using the upgrade program in update, so the files inside can be deleted. But if you delete Chrome directly, it will be automatically generated again. So you can consider cutting off this step, as long as Chrome cannot generate an update program in the Update folder, then Chrome cannot be upgraded.

1. Find C:\Program Files (x86)\Google\Updatethe path and delete all the content under the file:


insert image description here


2. Then right-click the Update folder, open Properties, click the "Security" tab, and click Edit


insert image description here

3. Set the full control right of System to Deny (System is the highest authority, after setting, Chrome will not have permission to move this file):


insert image description here


4. Then click OK one by one to finish. At this point, Chrome can permanently disable updates.


5. Open the Google Chrome settings to check whether the setting is successful:


insert image description here


The above is the solution to the cause of this error. Welcome to leave a message in the comment area to discuss whether it can be solved.If it is useful, please like and collect the article. Thank you for your support. The blogger has the motivation to keep recording the problems encountered.!!!

Thousands of full-stack VIP Q&A group to contact bloggers to help solve errors

Due to the limited time and energy of bloggers, there are too many private messages every day, and there is no way for every fan to reply in time, so reply to VIP fans first, and you can enter the thousand-person full stack by subscribing to the time-limited 9.9 paid column "100 Days Mastering Python from Getting Started to Employment" VIP answering group, get priority answering opportunities (code guidance, remote service), free prostitution 80G learning materials spree, column subscription address: https://blog.csdn.net/yuan2019035055/category_11466020.html

  • Advantages :The author gives priority to answering opportunities (code guidance, remote service), and many bigwigs in the group can hold together to keep warm (big factory internal promotion opportunities). This column is a complete set of teaching specially prepared for students with zero foundation and those who need advanced improvement , From 0 to 100, continue to advance and deepen, and there will be practical projects in the follow-up, so you can easily deal with interviews!

  • Column benefits :Resume guidance, internal referral for recruitment, weekly delivery of physical books, 80G full-stack learning videos, 300 IT e-books: Python, Java, front-end, big data, database, algorithm, crawler, data analysis, machine learning, interview question bank, etc.

  • Note : If you want to get a timely reply, communicate and learn with the big guys, after subscribing to the column, private message the blogger to enter the VIP Q&A group with thousands of peopleinsert image description here
    insert image description here

Free information acquisition, more fan benefits, follow the official account below to obtain

insert image description here

Guess you like

Origin blog.csdn.net/yuan2019035055/article/details/130594700