Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Python Web Scraping Cookbook

You're reading from   Python Web Scraping Cookbook Over 90 proven recipes to get you scraping with Python, microservices, Docker, and AWS

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781787285217
Length 364 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Michael Heydt Michael Heydt
Author Profile Icon Michael Heydt
Michael Heydt
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Title Page
Copyright and Credits
Contributors
Packt Upsell
Preface
1. Getting Started with Scraping FREE CHAPTER 2. Data Acquisition and Extraction 3. Processing Data 4. Working with Images, Audio, and other Assets 5. Scraping - Code of Conduct 6. Scraping Challenges and Solutions 7. Text Wrangling and Analysis 8. Searching, Mining and Visualizing Data 9. Creating a Simple Data API 10. Creating Scraper Microservices with Docker 11. Making the Scraper as a Service Real 1. Other Books You May Enjoy Index

Visualizing page relationships on Wikipedia


In this recipe we take the data we collected in the previous recipe and create a force-directed network visualization of the page relationships using the NetworkX Python library.

Getting ready

NetworkX is software for modeling, visualizing, and analyzing complex network relationships. You can find more information about it at: https://networkx.github.io. It can be installed in your Python environment using pip install networkx

How to do it

The script for this example is in the 08/06_visualizze_wikipedia_links.py file. When run it produces a graph of the links found on the initial Python page in Wikipedia:

Graph of the links

Now we can see the relationships between the pages!

How it works

The crawl starts with defining a one level of depth crawl:

crawl_depth = 1
process = CrawlerProcess({
    'LOG_LEVEL': 'ERROR',
    'DEPTH_LIMIT': crawl_depth
})
process.crawl(WikipediaSpider)
spider = next(iter(process.crawlers)).spider
spider.max_items_per_page = 5...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images