How to get the latest release version in Github only use python-requests?

Solution 1:

A direct way is to use GitHub API, it is easy to do and don't need xpath.


The URL should be:

https://api.github.com/repos/{owner}/{repo}/releases/latest

So if you want to get the latest release version of the repository. Here is an easy example only using the requests module:

import requests

response = requests.get("https://api.github.com/repos/v2ray/v2ray-core/releases/latest")
print(response.json()["name"])