Hi guys, I tried to find a way to extract ( and then run ) a js code from GitHub URL, so I began with this read and write python script but actually it brings all the GitHub page code including my code, can someone lead me to proper way:
my code:
url = "./test.csv"
resp = requests.get("github_url")
with open("test.csv", "w") as f:
f.write(resp.text)
That is one way to solve the problem. I’m not sure what your exact use case is. E.g. do you need to handle different Github repos or is this one off piece of code?
If you are using a same piece of code, then you might as well provide the raw URL directly to the program. Then your execute function would be less verbose. E.g.
def execute_scripts(raw, local_file):
r = requests.get(raw)
with open(local_file, "w") as f:
f.write(r.text)
CMD = f"python {local_file}"
os.system(CMD)