How it works

The sample simply writes the data to a file using standard Python file access functions.  It does it in an object oriented manner by using a standard interface for writing data and with a file based implementation in the FileBlobWriter class:

""" Implements the IBlobWriter interface to write the blob to a file """from interface import implementsfrom core.i_blob_writer import IBlobWriterclass FileBlobWriter(implements(IBlobWriter)):    def __init__(self, location):        self._location = location    def write(self, filename, contents):        full_filename = self._location + "/" + filename        print ("Attempting to write {0} bytes to {1}:".format(len(contents), filename))        with open(full_filename, 'wb') as outfile:            outfile.write(contents)        print("The ...

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.