Skip to content

Commit 2e4b17b

Browse files
committed
exercise_09
1 parent a234fd3 commit 2e4b17b

File tree

4 files changed

+39
-5
lines changed
  • .learn/resets
  • exercises

4 files changed

+39
-5
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import requests
2+
3+
def get_titles():
4+
# Your code here
5+
return None
6+
7+
8+
print(get_titles())

.learn/resets/10-get-post-tags/app.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import requests
2+
3+
def get_post_tags(post_id):
4+
# Your code here
5+
return None
6+
7+
8+
print(get_post_tags(146))

exercises/08-blog-post-author/app.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
import requests
22

3-
# Your code here
3+
# Your code here
4+
url = "https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php"
5+
response = requests.get(url)
6+
data = response.json()
7+
8+
# Getting the first post
9+
first_post = data["posts"][0]
10+
11+
# Getting the author dictionary
12+
author_dict = first_post["author"]
13+
14+
# Getting the author name
15+
author_name = author_dict["name"]
16+
17+
print(author_name)
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import requests
22

3-
def get_titles():
3+
def get_titles(web_page):
44
# Your code here
5-
return None
5+
titles = []
6+
response = requests.get(url)
7+
data = response.json()
8+
post = data["posts"]
9+
return post
610

7-
8-
print(get_titles())
11+
url = "https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php"
12+
print(get_titles(url))

0 commit comments

Comments
 (0)