Code Challenge 18 – Get Recommendations

By on 8 May 2017

There is nothing like a challenge to bring out the best in man. – Sean Connery

Hi Pythonistas, a new week, a new ‘bite’ of Python coding! This week we’ll do another API exercise: you will parse your Twitter feed searching for book / movie / music / you-name-it recommendations. Can you create a simple ParrotRead? Enjoy

Ah what if you don’t have or like Twitter?! Feel free to use any social media site where you can parse updates from people you follow or respect. Or use your favorite service, for example Goodreads in case of books.

The Challenge

  • Register an Twitter app and put the key/secret in a private (not under version control) config file or store them in env variables (os.environ). Again if using another API, follow similar steps.

  • Make a virtual environment and pip install Twython, Tweepy or your favorite Twitter API module.

  • Parse the updates from your followers. If you don’t follow a lot of people you could also work with a set of predefined Twitter handles.

  • Come up with a way to identify recommendations of your choice (books / movies / music / whatever you like).

  • We want recommendations, so check if the updates are positive (check this challenge where we used TextBlob, however use any tool you want).

Optional

  • Go beyond stdout by notifying the user either by tweet (already using the Twitter API so should be easy) or email (cache the results).

Bonus

  1. Tie this into a simple Flask app / front-end, here is some code to get Twitter login working in Flask.

  2. Make it more intelligent. Ask the user for his/her preferences upfront and use an algorithm (k-means clustering maybe?) to make relevant recommendations.


Getting ready

See our INSTALL doc how to fork our challenges repo to get cracking.

This doc also provides you with instructions how you can submit your code to our community branch via a Pull Request (PR). We will feature your PRs in our end-of-the-week challenge review (previous editions).

Feedback

If you have ideas for a future challenge or find any issues, please contact us or open a GH Issue.

Last but not least: there is no best solution, only learning more and better Python. Good luck!


Keep Calm and Code in Python!

— Bob and Julian

Want a career as a Python Developer but not sure where to start?