Is there any way by which we can programatically identify the latest version of chrome and upgrade accordingly. I would like to find the latest version of chrome and upgrade accordingly
After some googling, there seems to be no free API providing this.
Here is a candidate and they provide the latest version through api but you need to signup to get access to the api and if you need that info much you need to pay.
https://developers.whatismybrowser.com/api/
But why not try a simple way ourselves to get it from other sources?
I found two sources where I can get the latest chrome version.
First, the official link from Chrome team.
https://chromedriver.storage.googleapis.com/LATEST_RELEASE
But this does not give the version numbers for different platforms.
Second, checking https://www.whatismybrowser.com/guides/the-latest-version/chrome, we see that they provide the latest chrome versions for different platforms and we can scrape them using BeautifulSoup.
I wrote two simple Python functions getting the latest versions from the above sources.
import requests
from bs4 import BeautifulSoup as bs
def get_chrome_version():
url = "https://www.whatismybrowser.com/guides/the-latest-version/chrome"
response = requests.request("GET", url)
soup = bs(response.text, 'html.parser')
rows = soup.select('td strong')
version = {}
version['windows'] = rows[0].parent.next_sibling.next_sibling.text
version['macos'] = rows[1].parent.next_sibling.next_sibling.text
version['linux'] = rows[2].parent.next_sibling.next_sibling.text
version['android'] = rows[3].parent.next_sibling.next_sibling.text
version['ios'] = rows[4].parent.next_sibling.next_sibling.text
return version
def get_chrome_latest_release():
url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE"
response = requests.request("GET", url)
return response.text
print(get_chrome_version())
print(get_chrome_latest_release())
The test result is as follows.
78.0.3904.70
{'windows': '78.0.3904.97', 'macos': '78.0.3904.97', 'linux': '78.0.3904.97', 'android': '78.0.3904.96', 'ios': '78.0.3904.84'}
Hope this helps you get an idea. You can use the function as it is or maybe you can find another better source.