How to do it

The script for this example is in the 08/07_degrees_of_separation.py. The code is identical to the previous recipe, with a 2-depth crawl, except that it omits the graph and asks NetworkX to solve the degrees of separation between Python_(programming_language) and Dennis_Ritchie:

Degrees of separation: 1 Python_(programming_language)   C_(programming_language)    Dennis_Ritchie

This tells us that to go from Python_(programming_language) to Dennis_Ritchie we have to go through one other page: C_(programming_language).  Hence, one degree of separation. If we went directly to C_(programming_language),  it would be 0 degrees of separation.

Get Python Web Scraping Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.