How to find latest version number of python from web?

71 views Asked by At

I'm looking for getting latest version of python.

For example, I can find latest version of golang at https://go.dev/VERSION?m=text

Is there same thing as golang?

2

There are 2 answers

1
SIGHUP On BEST ANSWER

This may not be the best way to do it but you can interrogate the latest downloadable with this:

import requests
from bs4 import BeautifulSoup

(r := requests.get('https://www.python.org/downloads/')).raise_for_status()
soup = BeautifulSoup(r.text, 'lxml')
if (a := soup.find_all('a', class_='button')):
    print(a[0].text.split()[-1])

Output:

3.10.7
0
edp1096 On
$url = "https://www.python.org/downloads"
$doc = (Invoke-Webrequest $url).ParsedHTML # mshtml.HTMLDocumentClass
$as = $doc.Links

foreach($a in $as) {
    if ($el.className -eq "button") {
        Write-Output $el.innerText.split(" ")[-1] | Out-File -FilePath PYTHON_VERSION -encoding ASCII
        # Write-Output $el.innerText.split(" ")[-1]> "PYTHON_VERSION"
        break
    }
}

Like answer which I accepted, also it is possible to use powershell or sh, but this is not I want to do.

Unlike Go, the long live python never care these trivial things.

It make me sad.