Reputation: 3
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?
Upvotes: 0
Views: 98
Reputation: 3
$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.
Upvotes: 0
Reputation: 26993
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
Upvotes: 0