diff --git a/documentation.md b/documentation.md index 78285c12..230c003e 100644 --- a/documentation.md +++ b/documentation.md @@ -63,6 +63,7 @@ repository = github.Repository(username="nikhil25803", repository_name="scrape-u | Methods | Details | |---|-------------------------------------------------------------| | `.fork_count()` | Returns the number of forks of a repository. | +| `.get_contributors()` | Returns the number of contributors of a repository. | | `.topics()` | Returns the topics of a repository. | | `.pull_requests()` | Returns the number of pull requests opened in a repository. | | `.tags()` | Returns the last ten tags of a repository. | diff --git a/src/scrape_up/github/respository.py b/src/scrape_up/github/respository.py index debd0c4c..96c9eb24 100644 --- a/src/scrape_up/github/respository.py +++ b/src/scrape_up/github/respository.py @@ -97,6 +97,7 @@ def topics(self): try: topics = data.find_all(class_="topic-tag topic-tag-link") allTopics = [] + print(allTopics) for item in topics: allTopics.append(item.text) return allTopics # return list of topics @@ -120,6 +121,7 @@ def star_count(self): message = "Oops! No Stars found" return message + def pull_requests(self): """ Get the number of pull requests opened in a repository. @@ -128,7 +130,7 @@ def pull_requests(self): try: pull_requests = ( data.find_all(class_="UnderlineNav-item mr-0 mr-md-1 mr-lg-3")[2] - .find_all("span")[1] + .find_all("span")[1] .text.strip() ) return pull_requests @@ -240,3 +242,16 @@ def get_issues(self): except: message = "Failed to fetch list of issues" return message + + def get_contributors(self): + data= self.__scrape_page() + + try: + contributors = data.find_all("a", href=f"/{self.username}/{self.repository}/graphs/contributors") + contributor=[] + for it in contributors: + contributor.append(it.get_text()) + return contributor[0].strip() + except: + message="Oops! No contributors found" + return message diff --git a/src/scrape_up/github/users.py b/src/scrape_up/github/users.py index f2d86e29..a69d697a 100644 --- a/src/scrape_up/github/users.py +++ b/src/scrape_up/github/users.py @@ -32,6 +32,7 @@ def following(self): page = self.__scrape_page() try: following=page.find_all(class_="text-bold color-fg-default") + # print(page.find_all("span")) return following[1].text except: message = f"{self.username} not found !" @@ -251,6 +252,18 @@ def get_following_users(self): except: message = f"Following users not found for username {self.username}" return message + + def company(self): + page=self.__scrape_following_page() + try: + cmp=page.find(class_="Link--primary") + print(cmp.text) + # print(page.find_all("a")) + except: + message=f"Following users not found for username {self.username}" + return message + + def get_status(self): try: @@ -258,5 +271,6 @@ def get_status(self): t=data.find("div",class_="user-status-container position-relative hide-sm hide-md") return t.text.strip().replace('\n','') except: - return "Status not available" - + message=f"Status not found for username {self.username}" + return message +