Social News in 1000 Steps – Step 6

This entry is part 6 of 14 in the series Social News

Only small improvements this time of which the largest is using Wikipedia to test queries. I query against the live site, however if you are going to query at a larger scale for longer periods, you should consider for instance downloading the latest dump of the site and using that instead. If no results or too many results are found, I assume that the search phrase is either irrelevant or too broad.
The following snippet shows how to search Wikipedia:

import wikipedia
from joblib import Memory
 
 
memory = Memory(cachedir='.')
 
 
@memory.cache
def search_wiki(phrase):
    return wikipedia.search(phrase)
Series NavigationSocial News in 1000 Steps – Step 5Social News in 1000 Steps – Step 7
By the author of NumPy Beginner's Guide, NumPy Cookbook and Instant Pygame. If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
Share
This entry was posted in programming and tagged . Bookmark the permalink.