Apr-28-2020, 10:46 AM
I am interested in getting this snippet to work
but it uses call from subprocess module which is causing errors
I have replaced the first call that just created a directory with the os equivalent
to get past one call error only to be met by two more calls near end of the code.
I tried to replace those with popen but it didn't work.
Does anyone have an idea on what is going on here please?
but it uses call from subprocess module which is causing errors
Quote:Found 8 gists in 1 pages
[*] cloning git://gist.github.com/472d2acd06a1e1c498d7134f52dd7c46.git from page 1 [1/8]
Traceback (most recent call last):
File "C:/Python367/00-code snippets/possible snippets/scrape users gists.py", line 36, in <module>
call(['git', 'clone', '--quiet', gistUrl, path])
File "C:\Python367\lib\subprocess.py", line 267, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Python367\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Python367\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I have replaced the first call that just created a directory with the os equivalent
to get past one call error only to be met by two more calls near end of the code.
I tried to replace those with popen but it didn't work.
Does anyone have an idea on what is going on here please?
"""scrape a github users gists. origin: https://gist.github.com/dreizehnutters/6ac65948b506fbcd9f67ad0dd11ce50a """ from json import load import os import subprocess from subprocess import call from sys import argv from urllib import request GITHUB = "https://api.github.com/users/" USER = "steveshambles" if not os.path.isdir(USER): os.mkdir(USER) COUNT = 0 PERPAGE = 100 GISTCOUNT = load(request.urlopen(f"{GITHUB}{USER}"))['public_gists'] PAGES = (GISTCOUNT//PERPAGE)+2 print(f"Found {GISTCOUNT} gists in {PAGES-1} pages") for page in range(1, PAGES): for gist in load(request.urlopen(f"{GITHUB}{USER}/gists?page={page}&per_page={PERPAGE}")): COUNT += 1 gistd = list(gist['files'].keys())[0] gistUrl = f"git://gist.github.com/{gist['id']}.git" path = f"{USER}/{gist['id']}" print(f"[*] cloning {gistUrl} from page {page} [{COUNT}/{GISTCOUNT}]") #subprocess.Popen(['git', 'clone', '--quiet', gistUrl, path]) call(['git', 'clone', '--quiet', gistUrl, path]) call(['mv', path, f"{USER}/{gistd}"])>>>