我用来连接 git-repo 的以下代码列出了上述存储库路径中可用的所有文件。指定错误“socket.gaierror: [Errno 11001] getaddrinfo failed”失败
尝试使用用户凭据进行访问。但同样的错误出现了。
def requestGitCallToken(inputpath):
username = 'user'
token = 'token'
repos_url = inputpath + 'smuk29/codered'
# create a re-usable session object with the user creds in-built
gh_session = requests.Session()
gh_session.auth = (username, token)
# get the list of repos belonging to me
repos = json.loads(gh_session.get(repos_url).text)
print(repos)
# print the repo names
for repo in repos:
print(str(repo['name']))
requestGitCallToken("https://github.com/")
Traceback (most recent call last):
File "C:\Users\Deep\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "C:\Users\Deep\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "C:\Users\Deep\AppData\Local\Programs\Python\Python37\lib\socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed