Skip to content

Symomkuu/alx-system_engineering-devops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

149 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0-subs.py 1-top_ten.py 2-recurse.py 100-count.py

Write a function that queries the Reddit API (https://www.reddit.com/dev/api/) and returns the number of subscribers (not active users, total subscribers) for a given subreddit. If an invalid subreddit is given, the function should return 0.

Hint: No authentication is necessary for most features of the Reddit API. If you're getting errors related to Too Many Requests, ensure you're setting a custom User-Agent.

Requirements:

  • Prototype: def number_of_subscribers(subreddit)
  • If not a valid subreddit, return 0.
  • NOTE: Invalid subreddits may return a redirect to search results. Ensure that you are not following redirects.

Write a function that queries the Reddit API (https://www.reddit.com/dev/api/) and prints the titles of the first 10 hot posts listed for a given subreddit.

Requirements:

  • Prototype: def top_ten(subreddit)
  • If not a valid subreddit, print None.
  • NOTE: Invalid subreddits may return a redirect to search results. Ensure that you are not following redirects.

Write a recursive function that queries the Reddit API and returns a list containing the titles of all hot articles for a given subreddit. If no results are found for the given subreddit, the function should return None.

Hint: The Reddit API uses pagination for separating pages of responses.

Requirements:

  • Prototype: def recurse(subreddit, hot_list=[])
  • Note: You may change the prototype, but it must be able to be called with just a subreddit supplied. AKA you can add a counter, but it must work without supplying a starting value in the main.
  • If not a valid subreddit, return None.
  • NOTE: Invalid subreddits may return a redirect to search results. Ensure that you are not following redirects.

Your code will NOT pass if you are using a loop and not recursively calling the function! This /can/ be done with a loop but the point is to use a recursive function. :)

Write a recursive function that queries the Reddit API, parses the title of all hot articles, and prints a sorted count of given keywords (case-insensitive, delimited by spaces. Javascript should count as javascript, but java should not).

Requirements:

  • Prototype: def count_words(subreddit, word_list)
  • Note: You may change the prototype, but it must be able to be called with just a subreddit supplied and a list of keywords. AKA you can add a counter or anything else, but the function must work without supplying a starting value in the main.
  • Results should be printed in descending order, by the count, not the title. Words with no matches should be skipped and not printed.
  • Results are based on the number of times a keyword appears, not titles it appears in. 'java java java' counts as 3 separate occurences of java.
  • To make life easier, 'java.' or 'java!' or 'java_' should not count as 'java'
  • If no posts match or the subreddit is invalid, print a newline.
  • NOTE: Invalid subreddits may return a redirect to search results. Ensure that you are NOT following redirects.

Your code will NOT pass if you are using a loop and not recursively calling the function! This /can/ be done with a loop but the point is to use a recursive function. :)

Holberton logo

NAME OF PROJECT

Author: Elaine Yeung

Synopsis

This project introduces INSERT DESCRIPTION HERE

At the end of this project students should be able to explain to anyone, without the help of Google:

Resources

Project Requirements

  • Allowed editors: vi, vim, emacs
  • All your Bash script files will be interpreted on Ubuntu 14.04 LTS
  • All your files should end with a new line
  • A README.md file, at the root of the folder of the project, is mandatory
  • All your Bash script files must be executable
  • Your Bash script must pass shellcheck without any error
  • The first line of all your Bash scripts should be exactly #!/usr/bin/env bash
  • The second line of all your Bash scripts should be a comment explaining what is the script doing

The advantage of using #!/usr/bin/env bash instead of /bin/bash for instance is that it will make your script portable for different OS where Bash might be in a different location.

Project Breakdown

Task # Type Short description File name and link
0 Mandatory
1 Mandatory
2 Mandatory
3 Mandatory
4 Mandatory
5 Mandatory

About

about shell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors