Version 1.1.5
Written with Python 3.11.3
-
You have to use python 3.11 or above to be able to use this package.
py -m pip install --upgrade pip
python -m pip install --upgrade pip
pip install github4api
py -m pip install github4api
pip install -U github4api
py -m pip install --upgrade github4api
from github4api.scraper import Scrape # Scraper Class
from github4api.handlers.user_handler import UserHandler # User Handler Class
from github4api.handlers.request_handler import RequestHandler # Request Handler Class
def main():
# UserHandler serializes the value you given to the username param
# RequestHandler gets the Serialized data then sends a GET request to github servers and saves the page content in request variable
request: RequestHandler = RequestHandler(
url=UserHandler(username='shervinbdndev').serialize(),
).sendGetRequest(content=True)
# Scrape gets the variable as an arg
scraper: Scrape = Scrape(data=request)
# then we start using API by calling the startApi method
scraper.startApi(log=False) # log param is for safety, the default value is True but you can change it
# After all of these steps now you're free to use the API
print(scraper.followers)
print(scraper.followings)
print(scraper.biography)
print(scraper.json_data) # get full json data of user
if (__name__ == "__main__"):
main()
from github4api.scraper import Scrape
from github4api.handlers.user_handler import UserHandler
from github4api.handlers.request_handler import RequestHandler
def main():
request: RequestHandler = RequestHandler(
url=UserHandler(username='shervinbdndev').serialize(),
).sendGetRequest(content=True)
scraper: Scrape = Scrape(data=request)
scraper.startApi(log=False)
# Then your free to use the new method to get User's Repositories names
print(scraper.repositoriesNames(username='shervinbdndev'))
# ftl (first to last) is a new option that you can use to show the repositories from the first created to the last one
print(scraper.repositoriesNames(username='shervinbdndev', ftl=True)) # default value is False
# Also you can select the repository by index like below
print(scraper.repositoriesNames(username='shervinbdndev')[3]) # for example I want the 4th repository (It starts from 0 btw)
if (__name__ == "__main__"):
main()
from github4api.scraper import Scrape
from github4api.handlers.user_handler import UserHandler
from github4api.handlers.request_handler import RequestHandler
def main():
request: RequestHandler = RequestHandler(
url=UserHandler(username='shervinbdndev').serialize()
).sendGetRequest(content=True)
scraper: Scrape = Scrape(data=request)
scraper.startApi(log=False)
print(scraper.totalStarsGiven) # total stars given
print(scraper.profilePictureUrl) # profile picture url
# now using this new method you lets you check users repository's star count
print(scraper.checkRepositoryStars(
username='shervinbdndev', # user's username
repo_name='Quizino', # repository's name
))
if (__name__ == "__main__"):
main()
from github4api.scraper import Scrape
from github4api.handlers.user_handler import UserHandler
from github4api.handlers.request_handler import RequestHandler
def main():
user: UserHandler = UserHandler(username='shervinbdndev').serialize() # user instance
request: RequestHandler = RequestHandler(url=user).sendGetRequest(content=True) # send request by RequestHandler
scraper: Scrape = Scrape(data=request)
scraper.startApi(log=False)
print(scraper.lastYearContributions) # last year contributions
print(scraper.isRepositoryPublicArchive(username='shervinbdndev', repo_name='Quizino')) # check if repository is public archive => returns True or False
print(scraper.userHasReadMe(username='shervinbdndev')) # check if user has README.md
print(scraper.repositoryUsedLanguages(username='shervinbdndev', repo_name='github4api')) # get repository's used languages (also you can select by index)
print(scraper.userAchievements(username='shervinbdndev')) # get user's achievements (also you can select by index)
if (__name__ == "__main__"):
main()