Skip to content

Commit

Permalink
Merge pull request #134 from codesleep-Beperfect/main
Browse files Browse the repository at this point in the history
get_contributors() function completed
  • Loading branch information
nikhil25803 authored Feb 24, 2023
2 parents 7fc311c + 3a36a31 commit 2f1ae71
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
17 changes: 16 additions & 1 deletion src/scrape_up/github/respository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
18 changes: 16 additions & 2 deletions src/scrape_up/github/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 !"
Expand Down Expand Up @@ -251,12 +252,25 @@ 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:
data=self.__scrape_page()
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

0 comments on commit 2f1ae71

Please sign in to comment.