Skip to Main Content
Advanced Python Programming
book

Advanced Python Programming

by Dr. Gabriele Lanaro, Quan Nguyen, Sakis Kasampalis
February 2019
Intermediate to advanced content levelIntermediate to advanced
672 pages
16h 50m
English
Packt Publishing
Content preview from Advanced Python Programming

Implementation

Let's implement a program to fetch content from web pages, inspired by the tutorial from Michael Ford (https://docs.python.org/3/howto/urllib2.html). We have only take the simple part since the focus is to illustrate our pattern more than it is to build a special web-scraping tool.

We will use the urllib module to connect to web pages using their URLs; the core of the program would be the URLFetcher class that takes care of doing the work via a fetch() method.

We want to be able to track the list of web pages that were tracked, hence the use of the singleton pattern: we need a single object to maintain that global state.

First, our naive version, inspired by the tutorial but modified to help us track the list of URLs that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Python Programming - Second Edition

Advanced Python Programming - Second Edition

Quan Nguyen
Expert Python Programming - Third Edition

Expert Python Programming - Third Edition

Michał Jaworski, Tarek Ziadé, Cody Jackson
Python Workout

Python Workout

Reuven M. Lerner

Publisher Resources

ISBN: 9781838551216Supplemental Content