PyPI
pypi.org › project › PyGithub
PyGithub · PyPI
Details for the file pygithub-2.9.0-py3-none-any.whl. ... See more details on using hashes here. ... AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page
» pip install PyGithub
Readthedocs
pygithub.readthedocs.io › en › latest › introduction.html
Introduction — PyGithub 0.1.dev1+g7d1ba281e documentation
This package is in the Python Package Index, so pip install PyGithub should be enough.
GitHub
github.com › PyGithub › PyGithub
GitHub - PyGithub/PyGithub: Typed interactions with the GitHub API v3 · GitHub
Starred by 7.7K users
Forked by 1.9K users
Languages Python 99.6% | Shell 0.4%
GitHub
github.com › PyGithub › PyGithub › blob › 65fc5d3c29f59cb7c18d9854eae2eab8f8f53fb1 › github › Download.py
PyGithub/github/Download.py at 65fc5d3c29f59cb7c18d9854eae2eab8f8f53fb1 · PyGithub/PyGithub
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # # # # ############################################################################## · import github.GithubObject · · · class Download(github.GithubObject.CompletableGithubObject): """ This class represents Downloads as returned for example by http://developer.github.com/v3/todo ·
Author PyGithub
Readthedocs
pygithub.readthedocs.io › en › latest
PyGithub — PyGithub 0.1.dev1+g3a17ecf4a documentation
PyGithub · View page source · Introduction · Examples · Reference · Development ·
Readthedocs
pygithub.readthedocs.io › en › latest › github_objects › Download.html
Download — PyGithub 0.1.dev1+gf2540db50 documentation
This class represents Downloads · The reference can be found here https://docs.github.com/en/rest/reference/repos
SourceForge
sourceforge.net › projects › pygithub.mirror
PyGitHub download | SourceForge.net
Download PyGitHub for free. Typed interactions with the GitHub API v3. PyGitHub is a Python library to access the GitHub REST API. This library enables you to manage GitHub resources such as repositories, user profiles, and organizations in ...
Readthedocs
pygithub.readthedocs.io › en › latest › examples › Repository.html
Repository — PyGithub 0.1.dev1+gf2540db50 documentation
>>> repo = g.get_repo("PyGithub/PyGithub") >>> repo.stargazers_count 2086
Top answer 1 of 3
3
I ended up solving it by getting the "authenticity token" from the GitHub login page first, and then posting it:
import requests
from pathlib import Path
from github import Github
from bs4 import BeautifulSoup as bs
auth = 'username', 'password'
asset = Github(*auth).get_repo('user/repo').get_latest_release().get_assets()[0]
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36'
headers = {'user-agent': user_agent}
login_url = 'https://github.com/session'
session = requests.Session()
response = session.get(login_url, headers=headers)
authenticity_token = bs(response.text, 'lxml').find('input', attrs={'name': 'authenticity_token'})['value']
session.post(
login_url,
headers=headers,
data=dict(
commit='Sign in',
utf8='%E2%9C%93',
login=auth[0],
password=auth[1],
authenticity_token=authenticity_token
)
)
# Now I'm logged in properly, I can download the private repository assets
response = session.get(asset.browser_download_url, headers=headers)
save_to = Path.home() / 'Downloads' / asset.name
save_to.write_bytes(response.content)
2 of 3
2
I think Github updated the API requirements for the authentification of users. Hence Github('username', 'password') does not work anymore to get information about private repositories. Instead, use a Personal Access Token (https://github.com/settings/tokens) and generate one for your application. This way, you do also not have to save your login data in your script, which is much safer.
This simplifies the code a bit. I got an example for downloading data and safe it to a path and writing to a local variable. Yet I did not figure out how to download a non-text-based file (like pickle) to a local variable.
import requests
import os
from github import Github
from io import StringIO
import pandas as pd
import logging
from pathlib import Path
rawtoken = "githubtoken"
repository = "owner/reponame"
token = os.getenv('GITHUB_TOKEN', rawtoken)
g = Github(token)
headers = {'Authorization': 'token ' + rawtoken,
'Accept': 'application/octet-stream'}
session = requests.Session()
# asset_one: arbitrary file for
asset_one = g.get_repo(repository).get_latest_release().get_assets()[0]
response = session.get(r_regress.url, stream = True, headers=headers)
dest = Path() / "downloads" / asset_one.name
with open(dest, 'wb') as f:
for chunk in response.iter_content(1024*1024):
f.write(chunk)
# second asset: pandas dataframe -> safe in variable df
asset_two = g.get_repo(repository).get_latest_release().get_assets()[1]
df_response = session.get(asset_two.url, headers=headers)
data = StringIO(df_response.text)
df = pd.read_csv(data)
Readthedocs
pygithub.readthedocs.io › en › stable › github_objects › Download.html
Download — PyGithub 2.1.1 documentation
This class represents Downloads. The reference can be found here https://docs.github.com/en/rest/reference/repos · © Copyright 2023, Vincent Jacques Revision e584a90f
GitHub
github.com › PyGithub › PyGithub › issues › 1343
How do I download a file? · Issue #1343 · PyGithub/PyGithub
January 10, 2020 - I am trying to download a file and so far have reached here, also looked at #661 I have reached here so far. repo = client.get_repo(GIT_REPO) contents = repo.get_contents(file_path, ref=GIT_BRANCH) print (contents) #
Author vikas027
Kevin Sookocheff
sookocheff.com › posts › downloading directories of code from github using the github api
Downloading directories of code from Github using the Github API | Kevin Sookocheff
June 17, 2014 - This piece of code is fairly simple and relies on a couple of helper functions: get_sha_for_tag and download_directory. get_sha_for_tag will return the SHA commit hash given a branch or tag and download_directory will recursively download the files in the given directory. def get_sha_for_tag(repository, tag): """ Returns a commit PyGithub object for the specified repository and tag.
Readthedocs
pygithub.readthedocs.io › en › latest › github_objects › Repository.html
Repository — PyGithub 0.1.dev1+g24305f6d6 documentation
property downloads_url: str · Type: string · property events_url: str · Type: string · property fork: bool · Type: bool · property forks: int · Type: integer · property forks_count: int · Type: integer · property forks_url: str · Type: string ·
Readthedocs
pygithub.readthedocs.io › en › latest › apis.html
APIs — PyGithub 0.1.dev1+g7d1ba281e documentation
GET: github.Repository.Repository.get_download() or github.Repository.RepositorySearchResult.get_download()
Anaconda.org
anaconda.org › conda-forge › pygithub
pygithub - conda-forge
1 week ago - Organization created on Apr 11, 2015 · A community-led collection of recipes, build infrastructure, and distributions for the conda package manager