import requests
import os
import logging

try:
    import http.client as http_client
except ImportError:
    # Python 2
    import httplib as http_client
http_client.HTTPConnection.debuglevel = 1

logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

#path = 'https://gitlab.com/sharkfacts/shark-facts-for-jlpentest/-/blob/main/%2e%2e/%2e%2e/%2e%2e/22300820/repository/files/README.md'
path = 'https://gitlab.com/sharkfacts/shark-facts-for-jlpentest/-/blob/main/tmp.txt/raw?ref=e1a99b5e&'

start = 'https://gitlab.com/sharkfacts/shark-facts-for-jlpentest/-/blob/main/'

path = os.path.abspath(path[len(start)-1:])

url = 'https://gitlab.com/api/v4/projects/%u/repository/files/%s/raw?ref=main'%(123, path)
print(url)

res = requests.get(url)

print(res.text)

