I choose a public repositoryawesome-python as an example
suppose you want to access master/docs/CNAME contents
You can find the settings, for example
I choose a public repositoryawesome-python as an example
suppose you want to access master/docs/CNAME contents
You can find the settings, for example
import requests | |
token = "MY_SECRET_TOKEN" | |
owner = 'vinta' | |
repo = 'awesome-python' | |
path = 'docs/CNAME' | |
branch = 'master' # or sha1, for example: 6831740 | |
url = f'https://api.github.com/repos/{owner}/{repo}/contents/{path}?ref={branch}' | |
print(url) | |
r = requests.get(url, | |
headers={ | |
'accept': 'application/vnd.github.v3.raw', | |
# 'authorization': f'token {token}', # If you are want to read "public" only, then you can ignore this line. | |
} | |
) | |
print(r.text) | |
""" | |
Type | |
r.text: str | |
r.content: bytes | |
""" | |
# If you want to save it as a file, then you can try as below. | |
# f=open('temp.ico','wb') | |
# f.write(r.content) |