user3627332
user3627332

Reputation: 187

how to programmatically identify latest version of chrome

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

Upvotes: 0

Views: 2348

Answers (3)

Dmitry C
Dmitry C

Reputation: 1

http://omahaproxy.appspot.com is keeping release notes of chrome browser. This way you can fetch the latest stable for linux. Feel free to adjust according to your platform and wanted repo.

curl http://omahaproxy.appspot.com/all.json | jq '.[] | select (.os == "linux") | .versions | .[] | select(.channel == "stable") | .version' | tr -d '"'

Upvotes: 0

Simon
Simon

Reputation: 12488

One can look at Google's official Debian package repository and obtain version numbers straight from the horse's mouth at least for linux:

https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages

Upvotes: 1

JM217
JM217

Reputation: 737

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.

Upvotes: 1

Related Questions