-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractRepo.py
More file actions
29 lines (22 loc) · 789 Bytes
/
extractRepo.py
File metadata and controls
29 lines (22 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# This script is to extract the contents of a Github repo, and combine into one file.
import requests
from bs4 import BeautifulSoup
# List of all filenames to extract
files = [
"examplefiles",
]
# Base URL of the repository
base_url = "https://raw.githubusercontent.com/username/repo_name/main/"
# File to save the merged functions
output_file = ""
with open(output_file, "w") as outfile:
for file in files:
url = base_url + file
response = requests.get(url)
if response.status_code == 200:
outfile.write(f"% {file}\n")
outfile.write(response.text)
outfile.write("\n\n")
else:
print(f"Failed to retrieve {file}")
print(f"Functions merged into {output_file}")