#The above code should pull file form github and past in my local directory "C:\Users\HP"..not working as expected,the rpository is public'
Below is code:
import requests
def pull_files(repo_url, directory, filename):
"""
Pulls a specific file from the specified GitHub repository into the specified directory.
Args:
repo_url: The URL of the GitHub repository.
directory: The directory to store the files in.
filename: The name of the file to pull.
"""
response = requests.get(repo_url + "/blob/main/" + filename)
if response.status_code != 200:
raise Exception("Failed to get file.")
with open(os.path.join(directory, filename), "wb") as f:
f.write(response.content)
if __name__ == "__main__":
repo_url = "https://github.com/Hackerash008/Test/blob/main/.github/workflows/bard.py"
directory = "C:\\Users\\HP"
filename = "bard.py"
pull_files(repo_url, directory, filename)