O'Reilly logo

Python Network Programming Cookbook by Dr. M. O. Faruque Sarker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Searching for an article in Wikipedia

Wikipedia is a great site to gather information about virtually anything, for example, people, places, technology, and what not. If you like to search for something on Wikipedia from your Python script, this recipe is for you.

Here is an example:

Searching for an article in Wikipedia

Getting ready

You need to install the pyyaml third-party library from PyPI using pip or easy_install by entering $ pip install pyyaml or $ easy_install pyyaml.

How to do it...

Let us search for the keyword Islam in Wikipedia and print each search result in one line.

Listing 6.3 explains how to search for an article in Wikipedia, as shown:

#!/usr/bin/env python # -*- coding: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required