There's the requests
and urllib
page that can access http(s)
protocol pages in Python, e.g.
import requests
requests.get('stackoverflow.com')
but when it comes to chrome://
pages, e.g. chrome://settings/help
, the url libraries won't work and this:
import requests
requests.get('chrome://settings/help')
throws the error:
InvalidSchema: No connection adapters were found for 'chrome://settings/help'
I guess there's no way for requests or urllib to determine which chrome to use and where's the binary executable file for the browser. So the adapter can't be easily coded.
The goal here is to pythonically obtain the string Version 111.0.5563.146 (Official Build) (x86_64)
from the chrome://settings/help
page of the default chrome browser on the machine, e.g. it looks like this:
Technically, it is possible to get to the page through selenium
e.g.
from selenium import webdriver
driver = webdriver.Chrome("./lib/chromedriver_111.0.5563.64")
driver.get('chrome://settings/help')
But even if we can get the selenium driver to get to the chrome://settings/help
, the .page_source
is information for Version ...
is missing.
Also, other than the chrome version, the access to chrome://
pages would be used to retrieve other information, e.g. https://www.ghacks.net/2012/09/04/list-of-chrome-urls-and-their-purpose/
While's there's a way to call a Windows command line function to retrieve the browser version details, e.g. How to get chrome version using command prompt in windows , the solution won't generalize and work on Mac OS / Linux.