selenium Webdriverを使用すると簡単にこのタスクを実行できます。この場合、Google Chromeのバージョン番号を抽出します。ここで
は、すべての工程を説明するコメントとサンプルコードです:
from selenium import webdriver
# executable path should be the place where chrome driver is on the computer
driver = webdriver.Chrome(executable_path= '/users/user/Downloads/Chromedriver')
# This line tells the driver to go to the help section of chrome
driver.get('chrome://help')
# Because certain elements are stored in another Iframe, you must switch to this particular Iframe which is called 'help' in this case.
driver.switch_to.frame(driver.find_element_by_name('help'))
# retrive the text of the element and store it's text in a variable.
version_string = driver.find_element_by_id('version-container').text
# Now you can easily print it.
print version_string