Skip to content

Commit 0e796be

Browse files
committed
2 parents 658d411 + 0c50278 commit 0e796be

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

contribution.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,35 @@ pip install -r requirements.txt
6262

6363
Now you are done with the project setup, now you can make the changes you want or assign.
6464

65+
### Let say you want to scrape the avatar url of and user. Steps applying which we can do this
66+
+ At first we have to scrape the profile page of an user. For that we have defined a function in the user class as
67+
```python
68+
# scrape-up/src/scrape_up/github/__init__.py/
69+
class Users:
70+
71+
def __init__(self, username):
72+
self.username = username
73+
74+
def __scrape_page(self):
75+
username = self.username
76+
data = requests.get(f"https://github.com/{username}")
77+
data = BeautifulSoup(data.text, "html.parser")
78+
return data
79+
```
80+
81+
+ The `__scrape_page` is a private function defined to scrape any page.
82+
+ Now we have to create a function with approporiate name, in this case `get_avatar`.
83+
```python
84+
def followers(self):
85+
page = self.__scrape_page()
86+
try:
87+
followers = page.find(class_ = "avatar avatar-user width-full border color-bg-default")
88+
return followers["src"]
89+
except:
90+
message = f"{self.username} not found !"
91+
return message
92+
```
93+
+ When you do inspect element of the page, you will get to know class named `avatar avatar-user width-full border color-bg-default` contains thr avarat url.
6594

6695
Once you are done with the changes you wanted to add. Follow the steps to make the pull request.
6796
## Create and checkout to the new branch.
@@ -82,4 +111,4 @@ git commit -m "Enter your message here"
82111
```
83112
git push origin <branch_name>
84113
```
85-
---
114+
---

0 commit comments

Comments
 (0)