I'm automatically looking for various properties of README.md
files.
import requests
from typing import Final
FILE_NOT_FOUND: Final[int] = 404
GITHUB_URL: Final[str] = "https://github.com/"
repo_name_1 = "FasterXML/jackson-databind" # <--- main_name = 2.14
repo_name_2 = "Cacti/cacti" # <--- main_name = develop
repo_name_3 = "FFmpeg/FFmpeg" # <--- main_name = master
main_name = "develop"
repo_name = repo_name_2
url = f"{GITHUB_URL}/{repo_name}/blob/{main_name}/README.md"
if requests.head(url).status_code != FILE_NOT_FOUND:
print(f"README.md of {repo_name} exists")
# do something with README.md ...
I need to somehow put a regex instead of main_name
, is that doable?
EDIT:
Put in other words, can one use requests
to do the equivalent of find
:
find https://github.com/FasterXML/jackson-databind -name "README.md"