100% found this document useful (2 votes)
31 views

Web Scraping with Python Collecting Data from the Modern Web 1st Edition Ryan Mitchell - The ebook in PDF and DOCX formats is ready for download

The document promotes the ebook 'Web Scraping with Python' by Ryan Mitchell, providing a link for downloading and additional resources for related ebooks. It includes details about the book's content, such as chapters on building scrapers, advanced scraping techniques, and ethical considerations. The document also highlights the excitement and utility of web scraping as a programming skill.

Uploaded by

lottisbuliga
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
31 views

Web Scraping with Python Collecting Data from the Modern Web 1st Edition Ryan Mitchell - The ebook in PDF and DOCX formats is ready for download

The document promotes the ebook 'Web Scraping with Python' by Ryan Mitchell, providing a link for downloading and additional resources for related ebooks. It includes details about the book's content, such as chapters on building scrapers, advanced scraping techniques, and ethical considerations. The document also highlights the excitement and utility of web scraping as a programming skill.

Uploaded by

lottisbuliga
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Visit ebookfinal.

com to download the full version and


explore more ebooks or textbooks

Web Scraping with Python Collecting Data from the


Modern Web 1st Edition Ryan Mitchell

_____ Click the link below to download _____


https://ebookfinal.com/download/web-scraping-with-python-
collecting-data-from-the-modern-web-1st-edition-ryan-
mitchell/

Explore and download more ebooks or textbook at ebookfinal.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Flask Web Development Developing Web Applications with


Python 1st Edition Miguel Grinberg

https://ebookfinal.com/download/flask-web-development-developing-web-
applications-with-python-1st-edition-miguel-grinberg/

Automated Data Collection with R A Practical Guide to Web


Scraping and Text Mining 1st Edition Simon Munzert

https://ebookfinal.com/download/automated-data-collection-with-r-a-
practical-guide-to-web-scraping-and-text-mining-1st-edition-simon-
munzert/

The Modern Web Multi Device Web Development with HTML5


CSS3 and JavaScript 1st New edition Edition Peter Gasston

https://ebookfinal.com/download/the-modern-web-multi-device-web-
development-with-html5-css3-and-javascript-1st-new-edition-edition-
peter-gasston/

Data Mining the Web Uncovering Patterns in Web Content


Structure and Usage 1st Edition Zdravko Markov

https://ebookfinal.com/download/data-mining-the-web-uncovering-
patterns-in-web-content-structure-and-usage-1st-edition-zdravko-
markov/
Learn Java for Web Development Modern Java Web Development
1st Edition Vishal Layka

https://ebookfinal.com/download/learn-java-for-web-development-modern-
java-web-development-1st-edition-vishal-layka/

Data Management in the Semantic Web 1st Edition Hal Jin

https://ebookfinal.com/download/data-management-in-the-semantic-
web-1st-edition-hal-jin/

Web Mapping Illustrated Using Open Source GIS Toolkits 1st


Edition Tyler Mitchell

https://ebookfinal.com/download/web-mapping-illustrated-using-open-
source-gis-toolkits-1st-edition-tyler-mitchell/

Professional Python Frameworks Web 2 0 Programming with


Django and Turbogears Programmer to Programmer 1st Edition
Moore
https://ebookfinal.com/download/professional-python-frameworks-
web-2-0-programming-with-django-and-turbogears-programmer-to-
programmer-1st-edition-moore/

Building Web Applications with Erlang Working with REST


and Web Sockets on Yaws 1st Edition Zachary Kessin

https://ebookfinal.com/download/building-web-applications-with-erlang-
working-with-rest-and-web-sockets-on-yaws-1st-edition-zachary-kessin/
Web Scraping with Python Collecting Data from the
Modern Web 1st Edition Ryan Mitchell Digital Instant
Download
Author(s): Ryan Mitchell
ISBN(s): 9781491910290, 1491910291
Edition: 1
File Details: PDF, 6.10 MB
Year: 2015
Language: english
Web Scraping with Python
Collecting Data from the Modern Web

Ryan Mitchell

Boston
Web Scraping with Python
by Ryan Mitchell
Copyright © 2015 Ryan Mitchell. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or corporate@oreilly.com.

Editors: Simon St. Laurent and Allyson MacDonald Indexer: Lucie Haskins
Production Editor: Shiny Kalapurakkel Interior Designer: David Futato
Copyeditor: Jasmine Kwityn Cover Designer: Karen Montgomery
Proofreader: Carla Thornton Illustrator: Rebecca Demarest

June 2015: First Edition

Revision History for the First Edition


2015-06-10: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781491910276 for release details.

The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Web Scraping with Python, the cover
image, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the author disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.

978-1-491-91027-6
[LSI]
Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

Part I. Building Scrapers

1. Your First Web Scraper. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


Connecting 3
An Introduction to BeautifulSoup 6
Installing BeautifulSoup 6
Running BeautifulSoup 8
Connecting Reliably 9

2. Advanced HTML Parsing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13


You Don’t Always Need a Hammer 13
Another Serving of BeautifulSoup 14
find() and findAll() with BeautifulSoup 16
Other BeautifulSoup Objects 18
Navigating Trees 18
Regular Expressions 22
Regular Expressions and BeautifulSoup 27
Accessing Attributes 28
Lambda Expressions 28
Beyond BeautifulSoup 29

3. Starting to Crawl. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Traversing a Single Domain 31
Crawling an Entire Site 35
Collecting Data Across an Entire Site 38
Crawling Across the Internet 40
Crawling with Scrapy 45

4. Using APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
How APIs Work 50

iii
Common Conventions 50
Methods 51
Authentication 52
Responses 52
API Calls 53
Echo Nest 54
A Few Examples 54
Twitter 55
Getting Started 56
A Few Examples 57
Google APIs 60
Getting Started 60
A Few Examples 61
Parsing JSON 63
Bringing It All Back Home 64
More About APIs 68

5. Storing Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Media Files 71
Storing Data to CSV 74
MySQL 76
Installing MySQL 77
Some Basic Commands 79
Integrating with Python 82
Database Techniques and Good Practice 85
“Six Degrees” in MySQL 87
Email 90

6. Reading Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Document Encoding 93
Text 94
Text Encoding and the Global Internet 94
CSV 98
Reading CSV Files 98
PDF 100
Microsoft Word and .docx 102

Part II. Advanced Scraping

7. Cleaning Your Dirty Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109


Cleaning in Code 109

iv | Table of Contents
Data Normalization 112
Cleaning After the Fact 113
OpenRefine 114

8. Reading and Writing Natural Languages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119


Summarizing Data 120
Markov Models 123
Six Degrees of Wikipedia: Conclusion 126
Natural Language Toolkit 129
Installation and Setup 129
Statistical Analysis with NLTK 130
Lexicographical Analysis with NLTK 132
Additional Resources 136

9. Crawling Through Forms and Logins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137


Python Requests Library 137
Submitting a Basic Form 138
Radio Buttons, Checkboxes, and Other Inputs 140
Submitting Files and Images 141
Handling Logins and Cookies 142
HTTP Basic Access Authentication 144
Other Form Problems 144

10. Scraping JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147


A Brief Introduction to JavaScript 148
Common JavaScript Libraries 149
Ajax and Dynamic HTML 151
Executing JavaScript in Python with Selenium 152
Handling Redirects 158

11. Image Processing and Text Recognition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161


Overview of Libraries 162
Pillow 162
Tesseract 163
NumPy 164
Processing Well-Formatted Text 164
Scraping Text from Images on Websites 166
Reading CAPTCHAs and Training Tesseract 169
Training Tesseract 171
Retrieving CAPTCHAs and Submitting Solutions 174

Table of Contents | v
12. Avoiding Scraping Traps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
A Note on Ethics 177
Looking Like a Human 178
Adjust Your Headers 179
Handling Cookies 181
Timing Is Everything 182
Common Form Security Features 183
Hidden Input Field Values 183
Avoiding Honeypots 184
The Human Checklist 186

13. Testing Your Website with Scrapers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189


An Introduction to Testing 189
What Are Unit Tests? 190
Python unittest 190
Testing Wikipedia 191
Testing with Selenium 193
Interacting with the Site 194
Unittest or Selenium? 197

14. Scraping Remotely. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199


Why Use Remote Servers? 199
Avoiding IP Address Blocking 199
Portability and Extensibility 200
Tor 201
PySocks 202
Remote Hosting 203
Running from a Website Hosting Account 203
Running from the Cloud 204
Additional Resources 206
Moving Forward 206

A. Python at a Glance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

B. The Internet at a Glance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

C. The Legalities and Ethics of Web Scraping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

vi | Table of Contents
Preface

To those who have not developed the skill, computer programming can seem like a
kind of magic. If programming is magic, then web scraping is wizardry; that is, the
application of magic for particularly impressive and useful—yet surprisingly effortless
—feats.
In fact, in my years as a software engineer, I’ve found that very few programming
practices capture the excitement of both programmers and laymen alike quite like
web scraping. The ability to write a simple bot that collects data and streams it down
a terminal or stores it in a database, while not difficult, never fails to provide a certain
thrill and sense of possibility, no matter how many times you might have done it
before.
It’s unfortunate that when I speak to other programmers about web scraping, there’s a
lot of misunderstanding and confusion about the practice. Some people aren’t sure if
it’s legal (it is), or how to handle the modern Web, with all its JavaScript, multimedia,
and cookies. Some get confused about the distinction between APIs and web scra‐
pers.
This book seeks to put an end to many of these common questions and misconcep‐
tions about web scraping, while providing a comprehensive guide to most common
web-scraping tasks.
Beginning in Chapter 1, I’ll provide code samples periodically to demonstrate con‐
cepts. These code samples are in the public domain, and can be used with or without
attribution (although acknowledgment is always appreciated). All code samples also
will be available on the website for viewing and downloading.

vii
What Is Web Scraping?
The automated gathering of data from the Internet is nearly as old as the Internet
itself. Although web scraping is not a new term, in years past the practice has been
more commonly known as screen scraping, data mining, web harvesting, or similar
variations. General consensus today seems to favor web scraping, so that is the term
I’ll use throughout the book, although I will occasionally refer to the web-scraping
programs themselves as bots.
In theory, web scraping is the practice of gathering data through any means other
than a program interacting with an API (or, obviously, through a human using a web
browser). This is most commonly accomplished by writing an automated program
that queries a web server, requests data (usually in the form of the HTML and other
files that comprise web pages), and then parses that data to extract needed informa‐
tion.
In practice, web scraping encompasses a wide variety of programming techniques
and technologies, such as data analysis and information security. This book will cover
the basics of web scraping and crawling (Part I), and delve into some of the advanced
topics in Part II.

Why Web Scraping?


If the only way you access the Internet is through a browser, you’re missing out on a
huge range of possibilities. Although browsers are handy for executing JavaScript,
displaying images, and arranging objects in a more human-readable format (among
other things), web scrapers are excellent at gathering and processing large amounts of
data (among other things). Rather than viewing one page at a time through the nar‐
row window of a monitor, you can view databases spanning thousands or even mil‐
lions of pages at once.
In addition, web scrapers can go places that traditional search engines cannot. A
Google search for “cheapest flights to Boston” will result in a slew of advertisements
and popular flight search sites. Google only knows what these websites say on their
content pages, not the exact results of various queries entered into a flight search
application. However, a well-developed web scraper can chart the cost of a flight to
Boston over time, across a variety of websites, and tell you the best time to buy your
ticket.
You might be asking: “Isn’t data gathering what APIs are for?” (If you’re unfamiliar
with APIs, see Chapter 4.) Well, APIs can be fantastic, if you find one that suits your
purposes. They can provide a convenient stream of well-formatted data from one
server to another. You can find an API for many different types of data you might

viii | Preface
want to use such as Twitter posts or Wikipedia pages. In general, it is preferable to use
an API (if one exists), rather than build a bot to get the same data. However, there are
several reasons why an API might not exist:

• You are gathering data across a collection of sites that do not have a cohesive API.
• The data you want is a fairly small, finite set that the webmaster did not think
warranted an API.
• The source does not have the infrastructure or technical ability to create an API.
Even when an API does exist, request volume and rate limits, the types of data, or the
format of data that it provides might be insufficient for your purposes.
This is where web scraping steps in. With few exceptions, if you can view it in your
browser, you can access it via a Python script. If you can access it in a script, you can
store it in a database. And if you can store it in a database, you can do virtually any‐
thing with that data.
There are obviously many extremely practical applications of having access to nearly
unlimited data: market forecasting, machine language translation, and even medical
diagnostics have benefited tremendously from the ability to retrieve and analyze data
from news sites, translated texts, and health forums, respectively.
Even in the art world, web scraping has opened up new frontiers for creation. The
2006 project “We Feel Fine” by Jonathan Harris and Sep Kamvar, scraped a variety of
English-language blog sites for phrases starting with “I feel” or “I am feeling.” This led
to a popular data visualization, describing how the world was feeling day by day and
minute by minute.
Regardless of your field, there is almost always a way web scraping can guide business
practices more effectively, improve productivity, or even branch off into a brand-new
field entirely.

About This Book


This book is designed to serve not only as an introduction to web scraping, but as a
comprehensive guide to scraping almost every type of data from the modern Web.
Although it uses the Python programming language, and covers many Python basics,
it should not be used as an introduction to the language.
If you are not an expert programmer and don’t know any Python at all, this book
might be a bit of a challenge. If, however, you are an experienced programmer, you
should find the material easy to pick up. Appendix A covers installing and working
with Python 3.x, which is used throughout this book. If you have only used Python
2.x, or do not have 3.x installed, you might want to review Appendix A.

Preface | ix
If you’re looking for a more comprehensive Python resource, the book Introducing
Python by Bill Lubanovic is a very good, if lengthy, guide. For those with shorter
attention spans, the video series Introduction to Python by Jessica McKellar is an
excellent resource.
Appendix C includes case studies, as well as a breakdown of key issues that might
affect how you can legally run scrapers in the United States and use the data that they
produce.
Technical books are often able to focus on a single language or technology, but web
scraping is a relatively disparate subject, with practices that require the use of databa‐
ses, web servers, HTTP, HTML, Internet security, image processing, data science, and
other tools. This book attempts to cover all of these to an extent for the purpose of
gathering data from remote sources across the Internet.
Part I covers the subject of web scraping and web crawling in depth, with a strong
focus on a small handful of libraries used throughout the book. Part I can easily be
used as a comprehensive reference for these libraries and techniques (with certain
exceptions, where additional references will be provided).
Part II covers additional subjects that the reader might find useful when writing web
scrapers. These subjects are, unfortunately, too broad to be neatly wrapped up in a
single chapter. Because of this, frequent references will be made to other resources
for additional information.
The structure of this book is arranged to be easy to jump around among chapters to
find only the web-scraping technique or information that you are looking for. When
a concept or piece of code builds on another mentioned in a previous chapter, I will
explicitly reference the section that it was addressed in.

Conventions Used in This Book


The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program ele‐
ments such as variable or function names, databases, data types, environment
variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed by the user.

x | Preface
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter‐
mined by context.

This element signifies a tip or suggestion.

This element signifies a general note.

This element indicates a warning or caution.

Using Code Examples


Supplemental material (code examples, exercises, etc.) is available for download at
http://pythonscraping.com/code/.
This book is here to help you get your job done. In general, if example code is offered
with this book, you may use it in your programs and documentation. You do not
need to contact us for permission unless you’re reproducing a significant portion of
the code. For example, writing a program that uses several chunks of code from this
book does not require permission. Selling or distributing a CD-ROM of examples
from O’Reilly books does require permission. Answering a question by citing this
book and quoting example code does not require permission. Incorporating a signifi‐
cant amount of example code from this book into your product’s documentation does
require permission.
We appreciate, but do not require, attribution. An attribution usually includes the
title, author, publisher, and ISBN. For example: “Web Scraping with Python by Ryan
Mitchell (O’Reilly). Copyright 2015 Ryan Mitchell, 978-1-491-91029-0.”
If you feel your use of code examples falls outside fair use or the permission given
here, feel free to contact us at permissions@oreilly.com.

Preface | xi
Safari® Books Online
Safari Books Online is an on-demand digital library that deliv‐
ers expert content in both book and video form from the
world’s leading authors in technology and business.
Technology professionals, software developers, web designers, and business and crea‐
tive professionals use Safari Books Online as their primary resource for research,
problem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organi‐
zations, government agencies, and individuals. Subscribers have access to thousands
of books, training videos, and prepublication manuscripts in one fully searchable
database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-
Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco
Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt,
Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett,
Course Technology, and dozens more. For more information about Safari Books
Online, please visit us online.

How to Contact Us
Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.


1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at http://oreil.ly/1ePG2Uj.
To comment or ask technical questions about this book, send email to bookques‐
tions@oreilly.com.
For more information about our books, courses, conferences, and news, see our web‐
site at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

xii | Preface
Acknowledgments
Just like some of the best products arise out of a sea of user feedback, this book could
have never existed in any useful form without the help of many collaborators, cheer‐
leaders, and editors. Thank you to the O’Reilly staff and their amazing support for
this somewhat unconventional subject, to my friends and family who have offered
advice and put up with impromptu readings, and to my coworkers at LinkeDrive who
I now likely owe many hours of work to.
Thank you, in particular, to Allyson MacDonald, Brian Anderson, Miguel Grinberg,
and Eric VanWyk for their feedback, guidance, and occasional tough love. Quite a few
sections and code samples were written as a direct result of their inspirational sugges‐
tions.
Thank you to Yale Specht for his limitless patience throughout the past nine months,
providing the initial encouragement to pursue this project, and stylistic feedback dur‐
ing the writing process. Without him, this book would have been written in half the
time but would not be nearly as useful.
Finally, thanks to Jim Waldo, who really started this whole thing many years ago
when he mailed a Linux box and The Art and Science of C to a young and impression‐
able teenager.

Preface | xiii
PART I
Building Scrapers

This section focuses on the basic mechanics of web scraping: how to use Python to
request information from a web server, how to perform basic handling of the server’s
response, and how to begin interacting with a website in an automated fashion. By
the end, you’ll be cruising around the Internet with ease, building scrapers that can
hop from one domain to another, gather information, and store that information for
later use.
To be honest, web scraping is a fantastic field to get into if you want a huge payout for
relatively little upfront investment. In all likelihood, 90% of web scraping projects
you’ll encounter will draw on techniques used in just the next six chapters. This sec‐
tion covers what the general (albeit technically savvy) public tends to think of when
they think of “web scrapers”:

• Retrieving HTML data from a domain name


• Parsing that data for target information
• Storing the target information
• Optionally, moving to another page to repeat the process
This will give you a solid foundation before moving on to more complex projects in
part II. Don’t be fooled into thinking that this first section isn’t as important as some
of the more advanced projects in the second half. You will use nearly all the informa‐
tion in the first half of this book on a daily basis while writing web scrapers.
CHAPTER 1
Your First Web Scraper

Once you start web scraping, you start to appreciate all the little things that browsers
do for us. The Web, without a layer of HTML formatting, CSS styling, JavaScript exe‐
cution, and image rendering, can look a little intimidating at first, but in this chapter,
as well as the next one, we’ll cover how to format and interpret data without the help
of a browser.
This chapter will start with the basics of sending a GET request to a web server for a
specific page, reading the HTML output from that page, and doing some simple data
extraction in order to isolate the content that we are looking for.

Connecting
If you haven’t spent much time in networking, or network security, the mechanics of
the Internet might seem a little mysterious. We don’t want to think about what,
exactly, the network is doing every time we open a browser and go to http://
google.com, and, these days, we don’t have to. In fact, I would argue that it’s fantastic
that computer interfaces have advanced to the point where most people who use the
Internet don’t have the faintest idea about how it works.
However, web scraping requires stripping away some of this shroud of interface, not
just at the browser level (how it interprets all of this HTML, CSS, and JavaScript), but
occasionally at the level of the network connection.
To give you some idea of the infrastructure required to get information to your
browser, let’s use the following example. Alice owns a web server. Bob uses a desktop
computer, which is trying to connect to Alice’s server. When one machine wants to
talk to another machine, something like the following exchange takes place:

3
1. Bob’s computer sends along a stream of 1 and 0 bits, indicated by high and low
voltages on a wire. These bits form some information, containing a header and
body. The header contains an immediate destination of his local router’s MAC
address, with a final destination of Alice’s IP address. The body contains his
request for Alice’s server application.
2. Bob’s local router receives all these 1’s and 0’s and interprets them as a packet,
from Bob’s own MAC address, and destined for Alice’s IP address. His router
stamps its own IP address on the packet as the “from” IP address, and sends it off
across the Internet.
3. Bob’s packet traverses several intermediary servers, which direct his packet
toward the correct physical/wired path, on to Alice’s server.
4. Alice’s server receives the packet, at her IP address.
5. Alice’s server reads the packet port destination (almost always port 80 for web
applications, this can be thought of as something like an “apartment number” for
packet data, where the IP address is the “street address”), in the header, and
passes it off to the appropriate application – the web server application.
6. The web server application receives a stream of data from the server processor.
This data says something like:
- This is a GET request
- The following file is requested: index.html
7. The web server locates the correct HTML file, bundles it up into a new packet to
send to Bob, and sends it through to its local router, for transport back to Bob’s
machine, through the same process.
And voilà! We have The Internet.
So, where in this exchange did the web browser come into play? Absolutely nowhere.
In fact, browsers are a relatively recent invention in the history of the Internet, when
Nexus was released in 1990.
Yes, the web browser is a very useful application for creating these packets of infor‐
mation, sending them off, and interpreting the data you get back as pretty pic‐
tures, sounds, videos, and text. However, a web browser is just code, and code can be
taken apart, broken into its basic components, re-written, re-used, and made to do
anything we want. A web browser can tell the processor to send some data to the
application that handles your wireless (or wired) interface, but many languages have
libraries that can do that just as well.
Let’s take a look at how this is done in Python:
from urllib.request import urlopen
html = urlopen("http://pythonscraping.com/pages/page1.html")
print(html.read())
You can save this code as scrapetest.py and run it in your terminal using the com‐
mand:

4 | Chapter 1: Your First Web Scraper


Discovering Diverse Content Through
Random Scribd Documents
and, the discourse done, they rushed bravely into battle to defend
what they had heard.
Against these pious but strong-limbed confederates the wrath of
Guise was something terrible. It did not, like that of Francis I.—who
banqueted one day the unorthodox friends whom he burned the next
—alternate with fits of mercy. It raged without intermission, and
before it the Reformers of Alsatia were swept as before a blast in
whose hot breath was death. He spared neither sex nor age; and he
justified his bloody deeds by blasphemously asserting that he was
guided to them by the light of a cross which blazed before him in the
heavens. The church honored him with the name of “good and
faithful servant;” but there are Christian hearths in Alsatia where he
is still whisperingly spoken of as “the accursed butcher.”
When his own fingers began to hold less firmly the handle of his
sword, he also began to look among his children for those who were
most likely to carry out the mission of his house. His eye marked,
approvingly, the bearing of his eldest son Francis, Count D’Aumale;
and had no less satisfaction in the brothers of Francis, who, whether
as soldiers or priests, were equally ready to further the interests of
Lorraine, and call them those of Heaven. His daughter Mary he gave
to James V. of Scotland; and the bride brought destruction for her
dowry. Upon himself and his children, Francis I., and subsequently
Henry II., looked at last with mingled admiration and dread. Honors
and wealth were lavished upon them with a prodigal and even
treasonable liberality. The generous king gave to the insatiate Guise
the property of the people; and when these complained somewhat
menacingly, Guise achieved some new exploit, the public roar of
applause for which sanctioned a quiet enjoyment of his ill-gotten
treasures.
For the purpose of such enjoyment he retired to his castle at
Joinville. The residence was less a palace than a monastery. It was
inhabited by sunless gloom and a deserted wife. The neglected
garden was trimmed at the coming of the duke, but not for his sake
nor for that of the faithful Antoinette. Before the eyes of that faithful
wife he built a bower for a mistress who daily degraded with blows
the hero of a hundred stricken fields. He deprecated the rough usage
of the courtesan with tears and gold; and yet he had no better
homage for the virtuous mother of his children, than a cold civility.
His almost sudden death in 1550 was accounted for as being the
effect of poison, administered at the suggestion of those to whom his
growing greatness was offensive. The accusation was boldly graven
on his monument; and it is probably true. No one however, profited
by the crime.
The throne found in his children more dangerous supporters than he
had ever been himself; and the people paid for their popular
admiration with loss of life and liberty. The church, however, exulted;
for Claude of Lorraine, first Duke of Guise, gave to it the legitimate
son, Cardinal Charles, who devised the massacre of the day of St.
Bartholomew; and the illegitimate son, the Abbé de Cluny, who, on
that terrible day, made his dagger drink the blood of the Huguenots,
till the wielder of it became as drunk with frenzy as he was wont to
be with the fiery wine which was his peculiar and intense delight.
The first Duke of Guise only laid a foundation, upon which he left his
heirs and successors to build at their discretion. He had,
nevertheless, effected much. He had gained for his family
considerable wealth; and if he had not also obtained a crown, he had
acquired possession of rich crown-lands. The bestowing upon him of
these earned popular execration for the king; the people, at the
same time, confessed that the services of Guise were worthy of no
meaner reward. When King Francis saw that he was blamed for
bestowing what the recipient was deemed worthy of having granted
to him, we can hardly wonder that Francis, while acknowledging the
merits of the aspiring family, bade the members of his own to be on
their guard against the designs of every child of the house of
Lorraine.
But he was no child who now succeeded to the honors of his father,
the first duke. Francis of Guise, at his elevation to the ducal title, saw
before him two obstacles to further greatness. One was a weak king,
Henry II.; and the other, a powerful favorite, the Constable de
Montmorency, from whose family, it was popularly said, had sprung
the first Christian within the realm of France. Francis speedily
disposed of the favorite, and almost as speedily raised himself to the
vacant office, which he exercised so as to further his remote
purposes. In the meantime the king was taught to believe that his
crown and happiness were dependent on his Lorraine cousins, who,
on their side, were not only aiming at the throne of France for one
member of the house, but were aspiring to the tiara for a second; the
crown of Naples for a third—to influence in Flanders and in Spain,
and even to the diadem of Elizabeth of England, succession to which
was recognised as existing in them, by Mary Stuart, in case of her
own decease without direct heirs. It is said that the British Romanists
looked forward with unctuous complacency to the period when the
sceptre of this island should fall into the blood-stained grasp of a
“Catholic Guise.”
It was not only the fortune of Francis to repair the ill luck
encountered in the field by Montmorency, but to gain advantages in
fight, such as France had not yet seen. The Emperor Charles V. had
well-nigh got possession of beleaguered Metz, when Guise threw
himself into the place, rescued it from the Emperor, and swept the
Imperialists out of France. His fiery wrath cooled only in presence of
the wounded, to whom he behaved with gentle and helping courtesy.
His gigantic labors here brought on an attack of fever; and when he
was compelled to seek rest in his house at Marchez, a host of priests
and cardinals of his family gathered round his court, and excited him
to laughter by rough games that suited but sorrily with their calling.
The second duke inherited his father’s hatred for “heretics.” The
great Colligny had been his bosom friend; but when that renowned
Reformer gave evidence of his new opinions upon religious subjects,
then ensued, first a coldness, then fits of angry quarrelling, and at
last a duel, in which, though neither combatant was even scratched,
friendship was slain for ever. Duke Francis was prodigal like his
father, but then his brother, Cardinal Charles, was minister of the
finances: and the king and his mistress, Diana de Poictiers, cared
not how the revenue was managed, so that money was forthcoming
when necessity pressed. The consequence was, that the king’s
exchequer was robbed to supply the extravagances of Guise. But
then men began to associate with the name the idea of deliverance
from oppression; and they did not count the cost. And yet victory did
not invariably select for her throne the glittering helm of the aspiring
duke. The pope had selected him as commander of the papal army
acting against Naples, but intrigue paralyzed the arm which had
never before been conquered, and the pontiff showered epigrams
upon him instead of laurels.
In this momentary eclipse of the sun of his glory, the duke placed his
own neck under the papal heel. He served in the pope’s chapel as
an Acolyte, meekly bore the mantle of obese and sneering cardinals,
and exhibited a humility which was not without success. When at a
banquet given by a cardinal, Guise humbly sat down at the lower
end of the table, he asked a French officer who was endeavoring to
thrust in below him, “Why comest thou here, friend?” “That it might
not be said,” answered the soldier, “that the representative of the
King of France took the very lowest place at a priest’s table!”
From such reproaches Guise gladly fled, to buckle on his armor and
drive back an invasion of France by the Hispano-Flemings on the
north. The services he now rendered his country made the people
almost forget the infamy of their king, who was wasting life in his
capital, and the oppressive imposts of the financial cardinal, whom
the sufferers punningly designated as Cardinal La Ruine. The ruin he
achieved was forgiven in consideration of the glory accomplished by
his brother, who had defeated and destroyed the armies which
threatened the capital from the north; and who had effected much
greater glory by suddenly falling on Calais with a force of ten to one,
and tearing from the English the last of the conquests till then held
by them in France. Old Lord Wentworth, the governor, plied his
artillery with a roar that was heard on the English coast: but the roar
was all in vain. There was a proverb among our neighbors, and
applied by them to every individual of mediocre qualifications, that
“he was not the sort of man to drive the English out of France.” That
man was found in Guise; and the capital began naturally to contrast
him with the heartless king, who sat at the feet of a concubine, and
recked little of the national honor or disgrace. And yet, the medals
struck to commemorate the recovery of Calais bear the names only
of Henri and Diana. They omit all mention of the great liberator,
Guise!
The faults of Henri, however, are not to be entirely attributed to
himself. He had some feelings of compassion for the wretched but
stout-hearted Huguenots, with whom, in the absence of Guise, he
entered into treaties, which, Guise present, he was constrained to
violate! In pursuit of the visions of dominion in France, and of the
tiara at Rome, the ambitious house sought only to gain the suffrages
of the church and the faithful. To win smiles from them, the public
scaffolds were deluged with the blood of heretics; and all were
deemed so who refused to doff their caps to the images of the virgin,
raised in the highways at the suggestion of the duke and the
cardinal. This terrific persecution begat remonstrance; but when
remonstrance was treated as if it were rebellion, rebellion followed
thereupon; as, perhaps, was hoped for; and the swords of the
Guisards went flashing over every district in France, dealing death
wherever dwelt the alleged enemies of God, who dared to commune
with Him according to conscience, rather than according to Rome.
Congregations, as at Vassi, were set upon and slaughtered in cold
blood, without resistance. In the Huguenot “temple” of this last place
was found a Bible. It was brought to the duke. This noble gentleman
could spell no better than the great Duke of Marlborough; and Guise
was, moreover, worse instructed in the faith which he professed. He
looked into the Book of Life, unconscious of what he held, and with a
wondering exclamation as to what it might be all about, he flung it
aside, and turned to the further slaughter of those who believed
therein.
In such action he saw his peculiar mission for the moment, but he
was not allowed to pursue it unopposed. His intrigues and his
cruelties made rebels even of the princes of the blood; and Condé
took the field to revenge their wrongs, as well as those of the
Reformers. The issue was tried on the bloody day at Dreux, when
the setting sun went down on a Protestant army routed, and on
Condé a captive; but sharing the bed, as was the custom of the time,
of his proved victor Guise. Never did two more deadly enemies lie on
the same couch, sleepless, and full of mutual suspicion. But the
hatred of Condé was a loyal hatred; that of Guise was marked by
treacherous malignity. The Protestant party, in presence of that hot
fury, seemed to melt away like a snow-wraith in the sun. He and his
Guisards were the terror of the so-called enemies of the Faith. Those
whom he could not reach by the sword, he struck down by wielding
against them the helpless hand of the king, who obeyed with the
passiveness of a Marionette, and raised stakes, and fired the pile,
and gave the victim thereto, simply because Guise would so have it.
The duke received one portion at least of his coveted reward. At
every massacre of inoffensive Protestants, the Catholic pulpits
resounded with biblical names, showered down upon him by the
exulting preachers. When his banner had swept triumphantly over
successive fields, whose after-crops were made rich by heretical
blood, then did the church pronounce him to be a soldier divinely
armed, who had at length “consecrated his hands, and avenged the
quarrel of the Lord.”
Guise lived, it is true, at a period when nothing was held so cheap as
life. Acts of cruelty were but too common in all factions. If he
delivered whole towns to pillage and its attendant horrors, compared
with which death were merciful, he would himself exhibit
compassion, based on impulse or caprice. He was heroic, according
to the thinking of his age, which considered heroism as being
constituted solely of unflinching courage. In all other respects, the
duke, great as he was, was as mean as the veriest knave who trailed
a pike in his own bands. Scarcely a letter addressed to his officers
reached them without having been previously read to their right
worshipful master. There was scarcely a mansion in the kingdom,
whose lord was a man of influence, but that at that table and the
hearth there sat a guest who was the paid spy of Francis of Guise.
It is hardly necessary to add that his morality generally was on a par
with the particular specimens we have given of it. Crowds of
courtesans accompanied him to the camp, while he deliberately
exposed his own wife, Anne of Este, the sister of Tasso’s Leonora, to
the insulting homage of a worthless king. Emphatically may it be said
that the truth was not in him. He gloried in mendacity. No other
personage that I can call to mind ever equalled him in lying—except,
perhaps, those very highly professing heroes who swagger in Greek
tragedy. He procured, by a lie, the capital conviction of Condé. The
latter escaped the penalty, and taxed the duke with his falsehood.
Guise swore by his sword, his life, his honor, his very soul, that he
was innocent of the charge. Condé looked on the ducal liar with a
withering contempt, and turned from him with a sarcasm that should
have pierced him like a sword. Pointed as it was, it could not find
way through his corslet to his heart. He met it with a jest, and
deemed the sin unregistered.
There was a watchful public, nevertheless, observing the progress
made toward greatness by the chivalric duke, and his brother the
cardinal. Henry II. had just received the mortal blow dealt him at a
tournament by the lance of Montgomery. Francis II., his brother, the
husband of Mary Stuart, and therewith nephew to Guise, succeeded
to the uneasy throne and painful privileges of Henri. On the night of
this monarch’s decease, two courtiers were traversing a gallery of
the Louvre. “This night,” said one, “is the eve of the Festival of the
Three Kings.” “How mean you by that?” asked the other with a smile.
“I mean,” rejoined the first, “that to-morrow we shall have three
monarchs in Paris—one of them, King of France; the others Kings in
France—from Lorraine.”
Under the latter two, Duke and Cardinal, was played out the second
act of the great political drama of Lorraine. It was altogether a melo-
drama, in which there was abundance of light and shadow. At times,
we find the hero exhibiting exemplary candor; anon, he is the dark
plotter, or the fierce and open slayer of his kind. There are stirring
scenes of fights, wherein his adversaries draw their swords against
him, at the instigation of a disgusted King, who no sooner saw Guise
triumphant, than he devoted to death the survivors whom he had
clandestinely urged into the fray.
The battles were fought, on one side, for liberty of conscience; on
the other, for the sake of universal despotism. The bad side
triumphed during a long season; and field after field saw waving over
it the green banner of Lorraine. Catherine de Medicis, and her son
Charles IX., accompanied the Duke in more than one struggle, after
the short-lived reign of Francis II. had come to an end. They passed,
side by side, through the breach at Rouen; but accident divided them
at Orleans, where had assembled the gallant few who refused to
despair for the Protestant cause.
Guise beleaguered the city, and was menacingly furious at its
obstinacy in holding out. One evening he had ridden with his staff to
gaze more nearly at the walls, from behind which defiance was flung
at him. “You will never be able to get in,” remarked roughly a too
presuming official. “Mark me!” roared the chafed Duke, “yon setting
sun will know to-morrow how to get behind that rampart; and by
Heaven, so will I!” He turned his horse, and galloped back alone to
his quarters. He was encountered on his way by a Huguenot officer,
Poltrot de la Mer, who brought him down by a pistol-shot. The eyes
of the dying Duke, as he lay upon the ground, met for the last time
the faint rays of that departing sun, with which he had sworn to be up
and doing on the morrow. He died in his hut. His condition was one
of extreme “comfortableness.” He had robbed the King’s exchequer
to gratify his own passions;—and he thanked Heaven that he had
been a faithful subject to his sovereign! He had been notoriously
unfaithful to a noble and virtuous wife; and he impressed upon her
with his faltering lips, the assurance that “generally speaking” his
infidelity as a husband did not amount to much worth mentioning! He
confessed to, and was shriven by his two brothers, Cardinals John
and Charles. The former was a greater man than the Duke. The
latter was known in his own times and all succeeding, as “the bottle
cardinal,” a name of which he was only not ashamed, but his title to
which he was ever ostentatiously desirous to vindicate and establish.
The first Duke had acquired possession of crown-lands; the second
had at his disposal the public treasure; and the third hoped to add to
the acquisitions of his family the much-coveted sceptre of the Kings
of France.
Henri, surnamed Le Balafré, or “the scarred,” succeeded his father in
the year 1560. During the greater portion of his subsequent life, his
two principal objects were the destruction of Protestantism, and the
possession of the King’s person. He therewith flattered the national
vanity by declaring that the natural limits of France, on two sides,
were the Rhine and the Danube—an extension of frontier which was
never effected, except temporarily, in the latter days of Napoleon.
But the declaration entailed a popularity on the Duke which was only
increased by his victory at Jarnac, when the French Protestants not
only suffered defeat, but lost their leader, the brave and unfortunate
Condé. This gallant chief had surrendered, but he was basely
murdered by a pistol-shot, and his dead body, flung across an ass,
was paraded through the ranks of the victors, as a trophy. How far
the Duke was an accomplice in the crime, is not determined. That
such incidents were deemed lightly of by him, is sufficiently clear by
his own proclamation in seven languages, wherein he accused
Coligny as the instigator of the murder of the late Duke of Guise, and
set a price upon that noble head, to be won by any assassin.
For that so-called murder, Guise had his revenge on the day of St.
Bartholomew, when he vainly hoped that the enemies of his house
had perished for ever. On the head of more than one member of the
house of Guise rests the responsibility of that terrible day. During the
slaughter, Guise gained his revenge, but lost his love. The cries of
the victims were the nuptial songs chanted at the marriage-
ceremony of Henri of Navarre and Margaret, the King’s sister. The
latter had looked, nothing loath, upon the suit offered to her by
Guise, who was an ardent wooer. But the wooing had been roughly
broken in upon by the lady’s brother, the Duc d’Anjou, who declared
aloud in the Louvre, that if Guise dared look with lover’s eyes upon
“Margot,” he would run his knife into the lover’s throat! The threat
had its influence, and the unfaithful wooer, who had been all the
while solemnly affianced to a Princess Catherine of Cleves, married
that remarkable brunette, and showed his respect for her, by
speaking and writing of her as “that amiable lady, the negress.” It
may be noticed in passing, that the objection of D’Anjou to Guise as
a brother-in-law, was not personal; it had a political foundation. The
two dukes became, indeed, brothers-in-law; not by Guise marrying
the sister of D’Anjou, but by D’Anjou marrying the sister of Guise,
and by sharing with her the throne which he, subsequently, occupied
rather than enjoyed, as Henri III.
When summoned to the throne by the unedifying death of Charles
IX., Henry of Anjou was king of Poland. He escaped from that
country with difficulty, in order to wear a more brilliant but a more
fatal crown in France. He had no sooner assumed it, when he beheld
the Guises encircling him, and leaving him neither liberty nor will.
The Protestants were driven into rebellion. They found a leader in
Henry of Navarre, and Guise and his friends made war against them,
irrespective of the King’s consent, and cut in pieces, with their
swords, the treaties entered into between the two Henrys, without
the consent of the third Henri—of Guise and Lorraine. The latter so
completely enslaved the weak and unhappy sovereign, as to wring
from him, against his remonstrance and conviction, the famous
articles of Nemours, wherein it was solemnly decreed in the name of
the King, and confirmed by the signature of Guise, that,
thenceforward, it was the will of God that there should be but one
faith in France, and that the opposers thereof would find that
opposition incurred death.
There is a tradition that when Henri III. was told of this decree, he
was seated in deep meditation, his head resting upon his hand; and
that when he leaped to his feet with emotion, at the impiety of the
declaration, it was observed that the part of his moustache which
had been covered by his hand, had suddenly turned gray.
The misery that followed on the publication of these infamous
articles was widely spread, and extended to other hearths besides
those of the Huguenots. Sword, pestilence, and famine, made a
desert of a smiling country; and the universal people, in their
common sorrow, cursed all parties alike—“King and Queen, Pope
and Calvin,” and only asked from Heaven release from all, and
peace for those who suffered by the national divisions. The King,
indeed, was neither ill-intentional nor intolerant; but Guise so
intrigued as to persuade the “Catholic” part of the nation that Henri
was incapable. Faction then began to look upon the powerful subject
as the man best qualified to meet the great emergency. He fairly
cajoled them into rebellion. They were, indeed, willing to be so
cajoled by a leader so liberal of promises, and yet he was known to
be as cruel as he engaged himself to be liberal. He often kept his
own soldiers at a point barely above starvation; and the slightest
insubordination in a regiment entailed the penalty of death. To his
foes he was more terrible still. As he stood in the centre of a
conquered town that had been held by the Huguenots, it was sport to
him to see the latter tossed into the flames. On one occasion he
ordered a Huguenot officer to be torn asunder by young horses for
no greater crime than mutilating a wooden idol in a church. The
officer had placed the mutilated figure on a bastion of the city, with a
pike across its breast, as a satire on the guardianship which such a
protector was popularly believed to afford.
He could, however, be humane when the humor and good reason for
it came together. Thus he parted with a pet lioness, which he kept at
his quarters, on the very sufficient ground that the royal beast had,
on a certain morning, slain and swallowed one of his favorite
footmen! A commonplace lacquey he might have spared without
complaining; but he could not, without some irritation, hear of a valet
being devoured who, though a valet, had a profound belief that his
master was a hero.
The “Bartholomew” had not destroyed all the foes of the name of
Guise. What was not accomplished on that day was sought to be
achieved by the “League.” The object of this society was to raise the
Duke to the throne of Henri, either before or after the death of the
latter. The King was childless, and the presumptive heir to the
throne, Henri of Navarre, was a Protestant. The Lorrainers had
double reason, then, for looking to themselves. The reigning
sovereign was the last of three brothers who had inherited the
crown, and there was then a superstitious idea that when three
brothers had reigned in France, a change of dynasty was inevitable.
Guise fired his followers with the assurance that the invasion of
England, and the establishment of Popery there, should be an
enterprise which they should be called upon to accomplish. The King
was in great alarm at the “League,” but he wisely constituted himself
a member. The confederates kept him in the dark as to the chief of
their objects. The suspicious monarch, on the other hand,
encouraged his minions to annoy his good cousin of Lorraine. One of
these unworthy favorites, St. Megrim, did more: he slandered the
wife of Guise, who took, thereon, a singular course of trial and
revenge. He aroused his Duchess from her solitary couch, in the
middle of the night, hissed in her alarmed ear the damning rumor
that was abroad, and bade her take at once from his hands the
dagger or the poison-cup, which he offered her:—adding that she
had better die, having so greatly sinned. The offended and innocent
wife cared not for life, since she was suspected, and drank off the
contents of the cup, after protestation of her innocence. The draught
was of harmless preparation, for the Duke was well assured of the
spotless character of a consort whom he himself daily dishonored by
his infidelities. He kissed her hand and took his leave; but he sent a
score of his trusty-men into the courtyard of the Louvre, who fell on
St. Megrim, and butchered him almost on the threshold of the King’s
apartments.
The monarch made no complaint at the outrage; but he raised a
tomb over the mangled remains of his favorite minion, above which a
triad of Cupids represented the royal grief, by holding their stony
knuckles to their tearless eyes, affecting the passion which they
could not feel.
In the meantime, while the people were being pushed to rebellion at
home, the ducal family were intriguing in nearly every court in
Europe. Between the intrigues of Guise and the recklessness of the
King, the public welfare suffered shipwreck. So nearly complete was
the ruin, that it was popularly said, “The Minions crave all: the King
gives all; the Queen-mother manages all; Guise opposes all; the Red
Ass (the Cardinal) embroils all, and would that the Devil had all!”
But the opposition of Guise was made to some purpose. By
exercising it he exacted from the King a surrender of several strong
cities. They were immediately garrisoned by Guisards, though held
nominally by the sovereign. From the latter the Duke wrung nearly all
that it was in the power of the monarch to yield; but when Guise, who
had a design against the life of the Protestant Henri of Navarre,
asked for a royal decree prohibiting the granting of “quarter” to a
Huguenot in the field, the King indignantly banished him from the
capital. Guise feigned to obey; but his celebrated sister, the Duchess
of Montpensier, refused to share in even a temporary exile. This bold
woman went about in public, with a pair of scissors at her girdle,
which, as she intimated, would serve for the tonsure of brother Henri
of Valois, when weariness should drive him from a palace into a
monastery.
The King, somewhat alarmed, called around him his old Swiss body
guard, and as the majority of these men professed the reformed
faith, Guise made use of the circumstance to obtain greater ends
than any he had yet obtained. The people were persuaded that their
religion was in peril; and when the Duke, breaking his ban, entered
Paris and, gallantly attired, walked by the side of the sedan of
Catherine of Medicis, on their way to the Louvre, to remonstrate with
the unorthodox king, the church-bells gave their joyous greeting, and
the excited populace hung upon the steps of the Duke, showering
upon him blessings and blasphemous appellations. “Hosanna to our
new son of David!” shouted those who affected to be the most pious;
and aged women, kissing his garment as he passed, rose from their
knees, exclaiming, “Lord, now lettest thou thy servant depart in
peace, for mine eyes have seen thy salvation!”
The less blasphemous or the more sincere sufficiently expressed
their satisfaction by hailing him, as he went on his way, smiling, “King
of Paris!”
The sound of this title reached the ears of Henri. Coupling it with the
unauthorized return of Guise to court, he passed into alternate fits of
ungovernable wrath and profound melancholy. He was under the
influence of the latter when there fell on his ear, words which make
him start from his seat—“Percutiam pastorem, et dispergentur oves;”
and when the Monarch looked round for the speaker, he beheld the
Abbé d’Elbene, who had thus calmly quoted Scripture, in order to
recommend murder. The King, though startled, was not displeased.
On the contrary, he smiled; and the smile was yet around his lips,
and in his eyes, when Guise entered the presence, and mistook the
expression of the royal face for one of welcome. The Duke,
emboldened by what he saw, hurried through a long list of
grievances, especially dwelling on the lenity, not to say favor, with
which Henri treated the heretics generally. The sovereign made a
few excuses, which Guise heeded not; on the contrary, he hastened
to denounce the body of minions who polluted the palace. “Love me,
love my dog,” said Henri, in a hoarse voice. “Yes,” answered Guise,
peering into the royal and unnaturally sparkling eyes, “provided he
doesn’t bite!” The two men stood revealed before each other; and
from that hour the struggle was deadly. Henri would not give away,
with reference to his Swiss guard; and Guise, passing through Paris,
with his sword unsheathed, awoke the eager spirit of revolt, and
looked complacently on while the barricades were raised to impede
the march of the execrable Calvinistic Archers of the Guard. The
“King of Paris” earned a decisive victory; but before it was achieved,
the King of France hurried, in an agony of cowardly affright, from his
capital. He gazed for a moment on the city, as he departed, venting
curses on its ingratitude; for, said the fugitive Monarch, “I loved you
better than I did my own wife;”—which was indisputably true.
Guise might now have ascended the throne, had he not been too
circumspect. He deemed the royal cause lost, but he was satisfied
for the moment with ruling in the capital, as generalissimo. He
stopped the King’s couriers, and opened his letters. He confiscated
the property of Huguenots, and sold the same for his own benefit,
while he professed to care only for that of the Commonwealth.
Finally, he declared that the disturbed condition of affairs should be
regulated by a States-General, which he commanded rather than
prayed Henri to summon to a meeting at Blois. The King consented;
and the 18th of October, 1588, was appointed for the opening. Guise
entered the old town with his family, and a host of retainers, cased in
armor, and bristling with steel. Henri had his mother Catherine at his
side; but there were also a few faithful and unscrupulous followers
with him in the palace at Blois; and as he looked on any of those
who might happen to salute him in passing, the King smiled darkly,
and Percutiam pastorem fell in murmured satisfaction from his lips.
The saturnine monarch became, all at once, cheerful in his outward
bearing, even when Guise was so ruling the States as to make their
proceedings turn to the detriment of the monarchy. The Guise faction
became anxious for the safety of their leader, whose quarters were
in the palace; but when the King, in token of reconciliation begged
the Duke to participate with him in the celebration of the Holy
Sacrament, there was scarcely a man capable of interpreting the
manner of the times, who did not feel assured that under such a
solemn pledge of security, there lay concealed the very basest
treachery. Guise, over-confident, scorned alike open warning and
dark innuendoes. He was so strong, and his royal antagonist so
weak, that he despised the idea of violence being used against him
—especially as the keys of the palatial castle were in his keeping, as
“Grand-Master” of the Court.
The 23d of December had arrived. The King intimated that he should
proceed early in the morning, soon after daybreak (but subsequently
to holding a council, to which he summoned the Duke and Cardinal),
to the shrine of Our Lady of Clery, some two miles distant; and the
keys of the gates were demanded, in order to let Henri have issue at
his pleasure, but in reality to keep the Guises within, isolated from
their friends without. Larchant, one of the Archers of the Guard, also
waited upon the Duke, to pray him to intercede for himself and
comrades with the King, in order to obtain for them an increase of
pay. “We will do ourselves the honor,” said Larchant, “to prefer our
petition to your Highness, in the morning, in a body.” This was a
contrivance to prevent Guise from being surprised at seeing so many
armed men together in the King’s antechamber, before the council
was sitting. Henri passed a sleepless night. His namesake of Guise,
who had just sent his Duchess homeward, her approaching
confinement being expected, spent the whole of the same night in
the apartments of the Countess de Noirmoutier.
He was seen coming thence, before dawn, gayly dressed, and
proceeding to the Chapel of the Virgin, to perform his morning
devotions. Long before this, the King was a-foot, visiting the select
archers who had accepted the bloody mission of ridding the
perplexed monarch of his importunate adversary. He posted them,
altered the arrangements, reposted them, addressed them again and
again on the lawfulness of their office, and had some trouble to
suppress an enthusiasm which threatened to wake the Queen-
mother, who slept below, and to excite the suspicion of the Guards in
the vicinity. Staircase and hall, closet and arras, no coign of vantage
but had its assassin ready to act, should his fellows have failed.
Precisely at seven o’clock, Guise, attired in a light suit of gray satin,
and followed by Pericart, his secretary, entered the council-chamber,
where he found several members assembled; among others, his
younger brother, the “Bottle-Cardinal” de Guise. An hour passed
without the appearance of any message from the King, who was in
an inner apartment, now half-frightened at the pale faces of his own
confidants, and anon endeavoring to excite his own resolution, by
attempts to encourage theirs. It was a long and weary hour for all
parties. As it slowly passed away, Guise, he knew not wherefore,
grew anxious. He complained of the cold, and heaped billets of wood
upon the fire. He spoke of feeling sick, faint, and unnerved; and from
his silver sweetmeat-case he took a few bonbons, by way of
breakfast. He subsequently asked for some Damascus raisins, and
conserve of roses; but these, when supplied to him did not relieve
him of an unaccountable nervousness, which was suddenly
increased, when the eye next to the scar from which he derived his
appellation of Le Balafré, began to be suffused with tears. He
indignantly wiped away the unwelcome suffusion, and had quite
recovered as Rivol, Secretary of State, entered, and requested him
to attend on the King, who awaited him in his own chamber.
Guise gayly flung his bonbonnière across the council-table, and
laughingly bade the grave counsellors scramble for the scattered
sweets. He started up, overturned his chair in so doing, drew his thin
mantle around him, and with cap and gloves in hand, waved a
farewell to the statesmen present. He passed through two rooms,
and closely followed by various of the archers, reached the
tapestried entrance to the King’s cabinet. No one offered to raise the
arras for him. Guise lifted his own right arm to help himself at the
same time looking half-round at the archers who were near him. At
that moment, a dagger was buried in his breast, up to the very hilt.
The blow was delivered by Montsery, from behind. The Duke let fall
his hand to the pommel of his sword, when one assassin clung to his
legs, a second, also from behind, stabbed him in the neck; while a
third passed his weapon through the Duke’s ribs.
Guise’s first cry was, “Ho, friends!” His second, as Sarine ran him
through the lower part of the back, was, “Mercy, Jesus!” He struggled
faintly across the chamber, bleeding from a dozen wounds, in every
one of which sat death. The murderers hacked at him as he
staggered, and wildly yet feebly fought. All paused for a moment,
when he had reached the extreme end of the room, where he again
attempted to raise his sword; but in the act he rolled over, stone
dead, at the foot of the bed of Henri III.
At that moment the tapestry was raised, and the king, whispering “Is
it done?” approached the body, moodily remarking as he gazed upon
it, “He looks greater than he did when living.” Upon the person of the
duke was found a manuscript memorandum, in these words:—“To
maintain a war in France, I should require 700,000 livres per month.”
This memorandum served in the king’s mind as a justification of the
murder just committed by his orders. The body was then
unceremoniously rolled up in the Turkey carpet on which it had
fallen, was covered with quick lime, and flung into the Loire. Some
maimed rites were previously performed over it by Dourgin the royal
chaplain, who could not mutter the De Profundis without a running
and terrified commentary of “Christ!—the awful sight!” Guise’s
second cardinal-brother and the Archbishop of Lyons were murdered
on the following day; but the lesser victims were forgotten in the fate
which had fallen upon the more illustrious, yet certainly more guilty
personages.
The widow of Guise, soon after the dread event, gave birth to a son,
subsequently the Chevalier Louis de Guise. “The boy,” said the
bereaved lady, “came into the world with his hands clasped, as if
praying for vengeance on the assassins of his father.” Every male
member of the family whom the king could reach was now subjected
to arrest. The young heir of Balafré, Charles, now fourth Duke of
Guise, was now placed in close restriction in the Castle of Tours,
where, sleeping or waking, four living eyes unceasingly watched him
—voire même allant â la garderobe—but which eyes he managed to
elude nevertheless.
In the meantime Rome excommunicated the murderer of her
champion. Paris put on mourning; officials were placed in the street
to strip and scourge even ladies who ventured to appear without
some sign of sorrow. Wax effigies of the king were brought into the
churches, and frantically stabbed by the priests at the altar. The
priests then solemnly paraded the streets, chanting as they went,
“May God extinguish the Valois!”
The whole city broke into insurrection, and the brother of Guise, the
Duke de Mayenne, placed himself at the head of the “league,” whose
object was the deposing of the king, and the transferring of the
crown to a child of Lorraine. In the contest which ensued, Valois and
Navarre united against the Guisards, and carried victory with them
wherever they raised their banners. The exultation of Henri III. was
only mitigated by the repeated Papal summonses received by him to
repair to Rome, and there answer for his crime.
Henri of Navarre induced him to rather think of gaining Paris than of
mollifying the Pope; and he was so occupied when the double
vengeance of the church and the house of Guise overtook him in the
very moment of victory.
The Duchess de Montpensier, sister of the slaughtered duke, had
made no secret of her intentions to have public revenge for the deed
privately committed, whereby she had lost a brother. There was
precaution enough taken that she should not approach the royal
army or the king’s quarters; but a woman and a priest rendered all
precautions futile. The somewhat gay duchess was on unusually
intimate terms with a young monk, named Jacques Clement. This
good Brother was a fanatic zealot for his church, and a rather too
ardent admirer of the duchess, who turned both sentiments to her
own especial purpose. She whispered in his ears a promise, to
secure the fulfilment of which, he received with furious haste, the
knife which was placed in his hands by the handsomest woman in
France. It is said that knife is still preserved, a precious treasure, at
Rome.
However this may be, on the 1st of August, 1589, the young Brother,
with a weapon hid in the folds of his monkish gaberdine, and with a
letter in his hand, sought and obtained access to the king. He went
straightforward to his butcher’s work, and had scarcely passed
beneath the roof of the royal tent before he had buried the steel deep
in the monarch’s bosom. He turned to fly with hot haste to the lady
from whom he had received his commission; but a dozen swords
and pikes thrust life out of him ere he had made three steps in the
direction of his promised recompence.
She who had engaged herself to pay for the crime cared for neither
victim. She screamed indeed, but it was with a hysteric joy that
threatened to slay her, and which was only allayed by the thought
that the last King of the Valois race did not know that he had died by
a dagger directed by a sister of Guise.
In testimony of her exultation she distributed green scarfs, the color
of Lorraine, to the people of Paris. She brought up from the
provinces the mother of Clement, to whom was accorded the
distinction of a triumphal entry. Priests and people worshipped the
mother of the assassin as she passed wonderingly on her way; and
they blasphemously saluted her with the chanted words, “Blessed be
the womb that bare him, and the paps that gave him suck.” She was
led to the seat of honor at the table of Guise, and Rome sheltered
the infamy of the assassin, and revealed its own, by pronouncing his
work to be a god-like act. By authority of the Vatican, medals were
struck in memory and honor of the dead; but the Huguenots who
read thereon the murderer’s profession and name—Frère Jacques
Clement—ingeniously discovered therein the anagrammatic
interpretation “C’est l’enfer qui m’a crée”—“It is hell that created me.”
The last Valois, with his last breath, had named the Protestant Henri
of Navarre as his legal successor to the throne; but between Henri
and his inheritance there stood Rome and the Guise faction. Then
ensued the successive wars of the League, during which the heavy
Mayenne suffered successive defeats at the hands of Henri of the
snowy plume. While the contest was raging, the people trusted to the
pulpits for their intelligence from the scene of action. From those
pulpits was daily uttered more mendacity in one hour than finds
expression in all the horse-fairs of the United Kingdom in a year.
When famine decimated those who lived within the walls, the people
were reduced to live upon a paste made from human bones, and
which they called “Madame de Montpensier’s cake.”
Henri of Navarre, their deliverer, did not arrive before the gates of
Paris without trouble. In 1521, Charles of Guise, the young Duke,
had escaped most gallantly, in open day, from the Castle of Tours, by
sliding from the ramparts, down a rope, which simply blistered his
hands and made a rent in his hose. He was speedily accoutred and
in the field, with Spain in his rear to help him. Now, he was making a
dash at Henri’s person; and, anon, leaping from his camp-bed to
escape him. At other times he was idle, while his uncle Mayenne
pursued the cherished object of their house—that crown which was
receding from them more swiftly than ever. For the alert Bourbon, the
slow and hard-drinking Mayenne was no match. The latter thought
once to catch the former in his lady’s bower, but the wakeful lover
was gayly galloping back to his quarters before the trumpets of
Mayenne had sounded to “boot and saddle.” “Mayenne,” said the
Pope, “sits longer at table than Henri lies in bed.”
The gates of Paris were open to Henri on the 21st of March, 1591.
Old Cardinal Pellevi died of disgust and indignation, on hearing of
the fact. The Duchess of Montpensier, after tearing her hair, and
threatening to swoon, prudently concluded, with Henry IV., not only
her own peace, but that of her family. The chief members of the
house of Guise were admitted into places of great trust, to the injury
of more deserving individuals. The young Duke de Guise affected a
superabundant loyalty. In return, the King not only gave him the
government of several chief towns, but out of compliment to him
forbade the exercise of Protestant worship within the limits of the
Duke’s government! Such conduct was natural to a King, who to
secure his throne had abandoned his faith; who lightly said that he
had no cannon so powerful as the canon of the mass, and who was
destitute of most virtues save courage and good-nature. The latter
was abused by those on whom it was lavished; and the various
assaults upon his life were supposed to be directed by those very
Guises, on whom he had showered places, pensions, and pardons,
which they were constantly needing and continually deriding.
The young Duke of Guise enjoyed, among other appointments, that
of Governor of Marseilles. He was light-hearted, selfish, vain, and
cruel. He hanged his own old partisans in the city, as enemies to the
king; and he made his name for ever infamous by the seduction of
the beautiful and noble orphan-girl, Marcelle de Castellane, whom he
afterward basely abandoned, and left to die of hunger. He sent her a
few broad pieces by the hands of a lacquey; but the tardy charity
was spurned, and the poor victim died. He had little time to think of
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like