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.
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.
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).
Tie this into a simple Flask app / front-end, here is some code to get Twitter login working in Flask.
Make it more intelligent. Ask the user for his/her preferences upfront and use an algorithm (k-means clustering maybe?) to make relevant recommendations.
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).
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
Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.
"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H
"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B
"This is now my favourite first Python go-to reference." - Anthony L
"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S