'regex search for remote file with python requests

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"


Solution 1:[1]

After sorting XY problem of regex being completely irrelevant: What you are looking for is a GitHub API, which offers, among others, exactly this information. If you check out response for this request: https://api.github.com/repos/FasterXML/jackson-databind you can see that in the returned JSON one of the parameters is "default_branch" containing exactly what you need.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 matszwecja