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

Web Scraping with Python Collecting Data from the Modern Web 1st Edition Ryan Mitchell pdf download

The document is a comprehensive guide to web scraping using Python, authored by Ryan Mitchell and published by O'Reilly Media in 2015. It covers various topics including building scrapers, advanced scraping techniques, data storage, and legal considerations. The book aims to clarify misconceptions about web scraping and provides practical examples and tools for effective data collection from the modern web.

Uploaded by

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

Web Scraping with Python Collecting Data from the Modern Web 1st Edition Ryan Mitchell pdf download

The document is a comprehensive guide to web scraping using Python, authored by Ryan Mitchell and published by O'Reilly Media in 2015. It covers various topics including building scrapers, advanced scraping techniques, data storage, and legal considerations. The book aims to clarify misconceptions about web scraping and provides practical examples and tools for effective data collection from the modern web.

Uploaded by

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

Web Scraping with Python Collecting Data from

the Modern Web 1st Edition Ryan Mitchell pdf


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 textbooks


at ebookfinal.com
Here are some recommended products for you. Click the link to
download, or explore more at ebookfinal

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 [email protected].

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 [email protected].

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‐
[email protected].
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
general convulsions, preceded by symptoms of brain irritation or
compression.
Treatment. Three courses are available in the treatment of this
condition:—
1. Expectant treatment, combined with the application of pressure.
2. Aspiration and puncture.
3. Free exposure and further treatment according to the conditions
found.
In the majority of cases the local conditions preclude any attempt at
radical cure—the gap in the skull is large, the margins of the deficiency
are thinned and everted, and the brain enters largely into the formation
of the projecting mass. Furthermore, the dura mater is torn and in a
tag-like condition. Only in the most favourable cases—when the tumour
is small and the gap narrow—can radical treatment be advocated.
The application of pressure—without previous aspiration—exercises
but little effect on the size of the tumour and, under such treatment, the
danger of brain-compression is always present.
Aspiration with the object of removing the fluid constituents of the
tumour, and thus of reducing its size, has occasionally been followed by
disastrous results. Still, many cases were so treated in the pre-aseptic
days, and the modern methods of cleanliness should allow of better
results. One or more aspirations may be carried out, this treatment to be
followed by the application of steady and uniform pressure, preferably
with the aid of elastic bandages, the degree of compression depending
on the size and constituents of the tumour. The patient must be
watched most carefully, in order to guard against the development of
symptoms pointing to cerebral compression. Irritating injections should
never be used.
One must acknowledge that this mode of treatment has—except in
a few isolated cases—not produced very satisfactory results. Still, since
an open operation is usually out of the question, no other course
remains.
The after-history of these cases is not very encouraging. In one of
Weinlecher’s cases the child was living 5 years later, but pulsation was
still present. In Lucas’s case the patient died 21 months later from
meningitis. In Sir T. Smith’s case, pulsation was present 3 years after the
accident, and in Silcock’s there was no marked change for the better
after 11 years. On the other hand, a case reported by Golding Bird
steadily improved, and a second case reported by the same writer gave
every promise of a permanent cure. The two following cases have come
under my own observation:—
1. A female child, 11 months old, was knocked down by a van, and, on admission,
a large hæmatoma was seen situated over the right temporo-parietal region. The child
was semi-comatose, but recovered consciousness next day. The hæmatoma softening,
a gap in the bone was felt, one-third of an inch wide, and extending from the occipital
bone upwards and inwards to the middle line. The swelling increased in size when the
child cried. Pulsation was present and translucency was obtained. The tumour
increased in size for some days, but no untoward symptoms developed. For over one
month pressure was applied, but without much benefit, though the general condition
of the child was good. The edges of the gap became thickened. The child was then
removed from the hospital.
2. A male child fell 19 feet on to his head. He was concussed, and, on admission,
presented a hæmatoma over the right fronto-parietal region, and subconjunctival
hæmorrhage in the left orbit. Four days later he was apathetic and there was some
paresis of the left arm and leg. As the hæmatoma became softer, pulsation was noticed
over a small area, and, in this situation, the swelling increased in size on straining. A
fracture was detected later, one-third of an inch in diameter, and extending across the
left frontal bone to the right temporal region. Pressure was applied, the tumour
steadily decreased in size, and eventually the gap was completely closed.

Synopsis of 38 cases of traumatic cephalocele.


Sex. Males, 16. Females, 13. Sex not stated, 9.
Age at time of accident.
2 cases at birth.
9 in the first 6 months.
9 in the second 6 months.
14 between 1 and 2 years of age.
1 between 3 and 10.
1 between 10 and 15.
1 between 15 and 20.
1 between 20 and 30.
Region affected.
Right parietal, 17 cases.
Left parietal, 4 cases.
Other bones, right and left, 8 cases.
Parietal with others, 9 cases.
Parietal bone involved in 30 out of 38 cases.
Right side involved in 27 out of 38 cases.
Date of appearance of tumour.
7 cases in the first week.
11 cases in the second week.
4 cases in the third week.
4 cases between 2 and 18 months.
In the remainder, date uncertain.
Fractures of the skull resulting from injuries received at or
shortly after birth.
In the consideration of injuries to the skull and brain in babies the
following points should be noted:—
1. The bones of the skull are elastic and pliable, and consequently a
blow may lead to a ‘bending-in’, either temporary or permanent. Slight
depressions may exist without any associated fracture, but all major
depressions are accompanied by a fracture of the bone, especially
evident on examination of the internal table.
2. The fibrous tissue intervening between the component parts of
the vault tends to cause a limitation of the fracture to the particular
bone affected. Downward extension to the base is of infrequent
occurrence, but, when that region is involved, the fracture usually
follows the transbasic lines described in the section dealing with fracture
of the base of the skull (p. 82).
3. The dura is said to be more adherent to the inner table of the
skull than in adults. The relative infrequency in the young of extra-dural
hæmorrhage has been ascribed to this peculiarity. It would appear,
however, more probable that the rarity of such hæmorrhages results
from the bending-in, without splintering, of the bone.
4. The brain of the infant is equally—if not more—liable to bruising
and laceration, but the results are far less definite than in adults. There
can be no question that extensive cerebral injury may exist in the child
without leading to the development of any definite localizing symptoms.

FRACTURES OF THE VAULT

(a) Depressed fractures. Depressed fractures either result from


injury received during the birth of the child—whether from forceps
delivery or from the pressure exerted on the head by a contracted pelvis
—or from blows received shortly after birth.
Fig. 23. A Depressed Birth-fracture.

The depression, varying greatly in depth and extent, may be


situated over any part of the skull, but commonly involves the fronto-
parietal region. It is often obscured in the early stages by the presence
of an overlying hæmatoma, the condition perhaps only being discovered
after the absorption of the blood-clot. In many cases no symptoms
result, partly owing to the shallowness of the depression and partly due
to the situation of the lesion over one of the so-called ‘silent’ areas of
the brain. Under other circumstances the child may evidence the general
increase in the intracranial pressure by cyanosis, difficulty in respiration,
unconsciousness, and slow pulse. The anterior fontanelle will be tense,
and pulsation will be absent or greatly diminished—a feature of the
greatest diagnostic value. Localizing symptoms ensue when an extensive
depression is situated over the motor area, the extremities of the
opposite side being flaccid, or evidencing irritation by twitchings and
convulsions. The ready response of the infant to cortical irritation
frequently results in the early transformation of local twitchings into
general convulsions.
Course and treatment.
It is often stated that these depressed fractures remedy themselves in
the course of time, the development of the underlying cortex curing the
depression by the outward leverage exerted. In the minor degrees of
depression there may be some chance of such spontaneous cure. I am,
however, entirely opposed to the view that spontaneous cure is the rule,
and there can be no question that the more severe types of depression
remain as permanent defects unless surgical remedies are adopted.
Furthermore, even if the deformity should cure itself in time, the
intermediate dangers are not to be disregarded, for, during the process
of spontaneous cure, there is a decided liability for the depressed cortex
to lag behind in the process of development, or to undergo degenerative
changes as the result of the pressure exerted—with disastrous results on
the parts supplied by the region compressed. Mental deficiency,
paralyses, and contractures will result, and there is every reason to
believe that some cases of infantile paralysis are dependent on this
lesion.
The following case, recently under my care, adds further proof to
the statement that spontaneous cure is usually out of the question:—
The child, 10 weeks old, was admitted with a depressed fracture over the parieto-
frontal region, oval in shape, and about 31⁄2 inches in its long antero-posterior
diameter. The centre of the depression lay about 11⁄2 inches below a normal surface.
The injury was produced at birth (contracted pelvis), and frequent convulsions were
observed during the first few days of life. The fits then ceased, but the depression
became, if anything, more marked day by day. The child was then brought up to see
me. The depression was exposed by a suitable scalp-flap and a small trephine hole
made immediately posterior to the depression. The dura mater was stripped away from
the under surface of the bone and every effort made to remedy the depression. No
impression was thus made on the defect. The whole depressed area was then cut out
with a pair of scissors, the segment removed, wrapped up in a piece of gauze, and
forcibly manipulated in the hope that the depression could be overcome and the
segment placed back in the normal position. This attempt was also greeted with
failure. The segment was then placed back in the inverted position, the dural surface
external and vice versa. The segment required some trimming with the scissors before
it fitted accurately in position. The scalp-flap was then replaced. The child suffered but
very slightly from the operation, firm union was present in two weeks, and, six months
later, examination of the skull showed that the two sides were absolutely symmetrical.
It should be noted that, although the child was only 10 weeks old, and in spite of
the fact that the depression was fully exposed, it was quite impossible to lever up the
depressed bone. This hardly coincides with the views of those who maintain that birth-
depressions undergo spontaneous cure.
Taking all these facts into consideration, it would appear advisable
to adopt the following course:—slight depressions, situated in the region
of ‘silent’ areas of the brain, may be left for one or two weeks, and, in
the event of failure at spontaneous cure, the depression must be
elevated. In all the more serious cases, whether associated with
symptoms of brain-pressure or not, surgical interference is imperative.

A
B
Fig. 24. A Case of Depressed Birth-fracture. a, Before operation; b,
After operation. (For further description, see text.)

Operation. The baby would be well wrapped up and, after shaving


and cleansing of the scalp, the scalp-tourniquet applied. Babies stand
these operations exceedingly well so long as hæmorrhage is but slight.
A scalp-flap is turned down and a small trephine (1⁄2-inch diameter)
applied immediately to one side of the depression, the trephine circle
including the outer margin of the depressed area. The dura is stripped
away and a flat periosteal elevator introduced so that its apex
corresponds to the apex of the depression. An attempt is then made to
lever the depressed area in the outward direction. If that result be
attained, well and good. The flap is replaced and dressings applied. In
many cases, however, the elevated region promptly assumes its original
depressed position as soon as the elevator is removed, and, in other
cases, all attempts at rectification of the deformity are of no avail. Under
these circumstances, it is advisable to carry out the method advocated
by Nicholl—adopted in the case described above—the whole of the
depressed area being cut out with blunt-pointed scissors, reduced to a
more normal curvature by manipulation between layers of gauze, and
replaced in the inverted position, the original dural surface becoming
now external. This inversion is requisite, as it is usually quite impossible
—even under considerable pressure—to reduce the depression to a
permanently satisfactory degree.
Nicholl reports on 23 cases, the ages of the patients varying from 3
weeks to 8 years. The first 13 cases were treated by elevation. The
results obtained were most unsatisfactory, complete reduction of the
deformity seldom being attained, whilst recurrence, of a greater or
lesser degree, was the rule.
In the last 10 cases the inversion method was carried out, with, in
all cases, satisfactory results. Bony union was present in 10 days.
Four cases of depressed birth-fractures have come under my own
care. In two cases the depression was elevated—in both cases with
considerable difficulty—whilst in the other two cases, after failure of
leverage, Nicholl’s method was carried out, in both cases with eminently
satisfactory results.
(b) Fissured fractures. Fissured fractures are especially prone to
involve the parietal bone, and, in their direction, to follow the lines of
ossification. Thus, in the case of the parietal bone, the fissures will
radiate from the parietal prominence. There is also a certain tendency
for the fracture to remain limited to the particular bone affected.
The presence and extent of the fracture is commonly obscured by
the overlying hæmatoma, which is either subpericranial or
subaponeurotic. On the other hand, the hæmatoma may, from its size
and shape, supply evidence as to the nature of the underlying lesion.
Thus, when confined to the parietal bone, it may be inferred that the
fracture is also limited to that region. Again, when linear, the
presumption is that the fracture is of a similar nature. A definite
diagnosis may be impossible without aspiration or till after absorption of
the hæmatoma. The fissure will then be found to vary in extent from a
mere crack in the bone to a wide gap as broad or broader than the
width of the finger. In a case recently under my care the fissure, over
half an inch in breadth, extended from the vertex to the base, whilst
throughout the whole extent of the gap pulsation was readily obtained.
Fissured fractures in the very young possess another point of
interest in that the cleft often tends to increase, this being notably the
case when the fracture is associated with injury to underlying dura and
brain. The local and general increase of intracranial pressure not only
widens the gap, but also leads to thinning and eversion of the margins
of the deficiency with possible herniation of brain-matter—traumatic
cephalocele.
Symptoms. In many cases—in spite of the severity of the lesion—
there are no symptoms, the child appearing but little the worse for the
accident. In most cases, however, the child evidences symptoms of
brain-concussion, irritation, or compression, for which conditions
reference should be made to the sections dealing with those subjects.
It should be noted, however, that the anterior fontanelle supplies
evidence as to increase or decrease of intracranial pressure. In
concussion the fontanelle is depressed, in compression it is tense and
pulsation is absent or diminished. Irritation of the brain is evidenced by
irritability and general convulsions.
Treatment. In the absence of symptoms, or when the fracture is
associated with concussion or irritation, operative measures are contra-
indicated, the patient being treated after the general principles laid
down for those conditions.
When associated with symptoms of brain-compression, exploration
is almost always advisable, the scalp-tourniquet being applied and the
injured region exposed by a suitable scalp-flap. Depressed bone is
elevated, or the trephine applied so as to fully expose the underlying
dura mater. A bulging, non-pulsatile, and plum-coloured membrane
points to the existence of a subdural hæmatoma. The membrane is then
incised and the clot evacuated. Whenever possible the dura mater
should be sewn up and the scalp-flap replaced without drainage.
Operative measures are also indicated when a linear fracture gapes
widely—especially when the gap shows a tendency to increase in width.
The steps of such an operation are as follows:—
1. Expose the fracture throughout its whole length.
2. Cut away all pericranium or fibrous tissue that intervenes
between the margins of the cleft.
3. Separate the dura mater from the bone on either side of the cleft
for a distance of about 1⁄2 inch, at the same time sewing up any rents in
the membrane.
4. Bore a few holes through the skull—using an ordinary bradawl—
on either side of the cleft, the holes being placed about 1⁄2 inch apart.
5. Approximate and lace the margins of the cleft by means of fine
silver wire or strong catgut.
6. Sew up the flap without drainage.

BIRTH-HÆMORRHAGES

Extracranial hæmorrhages. As the result of injury sustained


during protracted labour, hæmatomata may develop beneath the
aponeurosis of the occipito-frontalis or underneath the pericranium, the
latter being the more common situation. The right side of the head is
the more frequently involved, and the parietal region is the part usually
affected. Occasionally these hæmatomata are bilateral and symmetrical.
The two varieties of cephalhæmatoma—subaponeurotic and
subpericranial—possess certain peculiarities that aid materially in their
differential diagnosis.
Subaponeurotic hæmatomata. The blood, though spreading widely
throughout the subaponeurotic space, tends to gravitate towards the
lower confines of that space, and, from the position assumed by the
patient, is most evident in the occipital region. The presence of the
blood is evidenced by œdema, doughiness, and ecchymosis.
Subpericranial hæmatomata. The blood is confined to the region of
the particular bone affected, usually the right parietal bone. This is due
to the fact that the pericranium blends at the margins of the bone with
the tissue intervening between that bone and the neighbouring parts of
the skull.
Subpericranial hæmatomata present further peculiarities. The
tumour is usually more or less circular in outline, and fluctuates freely. It
may arise immediately after the birth of the child, but, more commonly,
some two or three days elapse before attention is drawn to its existence.
Within a few days clotting occurs at the periphery of the hæmatoma
with the formation of a circumferential ridge. The central portion of the
clot remains soft but tense, so much so that firm pressure is required
before the examining finger is enabled to feel the underlying bone.
These cephalhæmatomata are not infrequently mistaken for depressed
fractures, but no difficulty should be experienced if the existence of the
circumferential ridge be appreciated and if the underlying bone can be
felt at the centre of the tumour. In cases of doubt the blood should be
drawn off by aspiration and the swelling again examined.
For differential diagnosis, see p. 57.
Treatment. The less extensive hæmatomata require no active
surgical treatment, the absorption of the clot being aided by protection
of the part and by cooling lotions.
Similar expectant treatment is generally advised with regard to the
extensive subpericranial hæmatomata, but as infection of the clot may
take place, and as its resolution invariably requires a considerable period
of time—often many weeks—more active measures can be adopted. The
region of the hæmatoma is carefully shaved and cleansed, and, under
local anæsthesia, a small incision made through the scalp, the clot
squeezed out, and firm pressure applied. Under this form of treatment
the patient is well within a few days.
Intracranial birth-hæmorrhages. Attention was first drawn to
the question of intracranial birth-hæmorrhages by Little, who showed
that a history of difficult labour could be obtained in a large percentage
of cases in which children in after-life suffered from uni- or bilateral
spastic paraplegia; hence the name, ‘Little’s disease’ or birth palsy.
Further information was supplied by Sarah MacNutt, and the whole
question was fully investigated by Harvey Cushing.
In all cases a history of difficult and protracted labour can be
obtained, with considerable post-partum respiratory difficulties, the child
being described as ‘blue in the face’ for some hours after birth.
The stress and strain which the advancing head undergoes, and the
consequent moulding and overlapping of the various segments of the
skull, exposes the brain to great alterations of pressure, and throws
considerable tension on the intracranial veins. It is, in fact, rather
surprising that birth-hæmorrhages are not more common.
The hæmorrhages may be wholly within the meshes of the pia-
arachnoid system, but, in the great majority of cases, the lesion is more
serious, and the extravasation comes to lie within the subdural space.
Occasionally the bleeding takes place beneath the tentorium
cerebelli, the blood-clot lying in relation to the pons and medulla. Such
hæmorrhages are said to be observed only in vertex presentations. The
more common supratentorial hæmorrhages—usually resulting from
difficult breech presentations—either remain more or less localized to a
certain region of the cortex, or become widely diffused over the surface
and base of the brain.
It is probable that Cushing is correct in his observations with
respect to the source of these supratentorial hæmorrhages. He states
that the blood is derived from one or more radicles of the superior
longitudinal sinus, especially from those veins which, in their upward
passage in the sulci of the brain, leave their cerebral beds for a short
and comparatively unprotected course, immediately previous to their
entry into the lacunæ laterales of the superior longitudinal sinus.
In addition, he points to the very important fact that the localized
hæmorrhages are commonly situated in relation to the mid-cerebral
cortex, close to the sinus, and on one or both sides of the falx cerebri.
In addition, therefore, to the symptoms of general cerebral compression,
certain definite localizing symptoms are to be observed, these being in
direct proportion to the size of the clot.
In an analysis of 74 autopsies on infants still-born or dying within
the first few days, Archibald[11] found ‘intrameningeal’ hæmorrhage in
32, in 19 of which it was of considerable extent: and in 5 others there
was extra-dural hæmorrhage. In only two or three was effused blood
found within the cerebral cortex. The importance of these facts from a
surgical point of view cannot be over-estimated.
Fig. 25. Diagram to illustrate the Effects and Position of a Birth-hæmorrhage.
sc., Scalp; b., Bone; d.m., Dura mater; br., Brain; s.l.s., Superior longitudinal
sinus; c.v.1, The protected part of a superficial cerebral vein; c.v.2, The
unprotected part of a superficial cerebral vein; c., The subdural clot, exercising
pressure on (1) the cortical leg arm, (2) the arm area, and (3) the face area.

Symptoms. Besides the history of protracted labour and the


‘blue’ asphyxiated appearance of the baby, other evidence is to hand
with respect to both general and local increase of brain-pressure.
The general increase is evidenced first and foremost by the
bulging and non-pulsatile anterior fontanelle. The fontanelle may be
regarded as an index of intracranial pressure. The margins of the
fontanelle are outlined with some difficulty, and, owing to the free
communication between the intra- and extra-cranial venous systems,
the scalp-veins are unduly prominent. The general condition of the
child varies according to rise of intracranial pressure. In the more
serious cases it may be impossible to arouse the patient: in the
slighter hæmorrhages the child may appear but little the worse, with
the exception, perhaps, of being rather more irritable than usual.
The effect of the pressure on the medullary centres is shown by
respiratory difficulties—irregularities of rhythm, &c.—some
retardation in pulse-rate, and increase in blood-pressure. The
reflexes are increased and the child is readily thrown into general
convulsions.
The effect of the localized pressure on the upper Rolandic
centres seldom becomes evident till after the lapse of a few days—
and often after a longer period—when muscular weakness,
twitchings, rigidity, or paralysis—more especially of the contralateral
lower extremity—becomes apparent. The mother often draws
attention to the fact that the child does not move one of its legs
properly.
When the extravasation is extensive, spreading downwards over
other motor areas, the upper extremities and even the face may be
involved.
When a small hæmorrhage is present, situated on either side of
the falx cerebri, both lower extremities suffer and diplegia results.
In some cases, chemosis of the conjunction, œdema of the lids,
and proptosis have been observed. In any case an ophthalmoscopic
examination should be carried out. Frequently some fullness of the
retinal veins and diminution in the calibre of the arteries supply
confirmatory evidence.
In the event of doubt in diagnosis, lumbar puncture should be
carried out. It should be noted, however, that although the positive
evidence of free blood corpuscles points to subdural hæmorrhage,
yet that absence of blood in the fluid withdrawn does not exclude
the possibility of a localized and more or less encapsulated
hæmorrhage. In the event of failure at recognition of the serious
lesion present, disastrous results will ensue—monoplegia, diplegia,
hemiplegia, epilepsy, and idiocy.
Treatment. The age of the patient must not be allowed to
weigh in the balance against operative treatment, for, if due
precautions be taken, the new-born child stands operation well.
Cushing points out that ‘the possibilities of surgical relief are limited
to the first week or two after the hæmorrhage has occurred, for old
cortical scars can neither be helped by medicine nor by the scalpel’.
The clot can be exposed by craniectomy or by craniotomy. The
latter operation results in a more complete exposure, but the shock
is undoubtedly more severe. Exposure by craniotomy is advocated
by Cushing, and carried out in the following manner: ‘An omega-
shaped incision just within the outer margin of the parietal bone is
carried down to the bone through the scalp and pericranium, and
the latter is scraped away so as to expose the thin serrated edge of
the parietal bone. Under this a blunt dissector is passed, so that the
edge of the bone is tilted up, and then, with a proper cutting
instrument (strong blunt-pointed scissors suffice), the bone is incised
in a line conforming with the skin incision 1 centimetre or more
within the parietal margin. The parietal bone is then broken across
at its base. The dura is opened by a curved incision some distance
within the bony margin, and the superficial clot broken away or lifted
off in fragments, or irrigated away with a gentle stream of warm
saline solution. The dura should be accurately sutured, the bone
replaced, and the skin closed with suture.’
He reports on 9 cases so treated, with 4 recoveries, apparently
complete and permanent. The fatal cases were all associated with
extensive extravasation over the entire hemisphere. In 3 cases
bilateral exposure was necessitated.
Taking, however, the question into more general consideration,
it would appear that equally satisfactory results can be obtained,
with a lesser degree of operative danger, by carrying out
craniectomy in the manner described in the treatment of ‘traumatic
subdural hæmorrhage’ (see p. 156).

DERMOIDS

Dermoids, in this region of the body, are almost invariably


situated in the middle line between nasion and inion, though cases
have been described in which congenital tumours, dermoid-like in
nature, were situated over the mastoid process and in other regions.
They occur with the greatest frequency over the anterior
fontanelle and in the region of the external occipital protuberance. In
the latter situation they are specially prone to possess those deep
attachments to the dura mater which are further alluded to below. In
the great majority of cases careful examination will show that the
tumour occupies a depression in the bone, saucer-like in nature, in
which the tumour rests. They are seldom freely movable, and are
often markedly fixed, being either attached to the pericranium or to
deeper structures. They are not attached to the overlying skin. The
tumour is irreducible, and pulsation is absent except in those rare
cases where, in the presence of a wide gap in the skull, transmitted
pulsation may be obtained.
On careful dissection it may be found that the tumour
communicates, by means of a small hole in the skull, with the
underlying membranes. In more exceptional cases a wide gap in the
skull may be found by means of which the dermoid obtains
extensive connexion with the dura mater and even with the brain. In
rare cases the dermoid may be pedunculated.
Bland Sutton drew attention to this frequent connexion between
the dermoid and the membranes of the brain, showing further that
the entire tumour may lie on the inner side of the occipital bone.
The following account affords further information as to the
nature and origin of cephalic dermoids.
‘Morphologically considered, the bony framework of the skull is an additional
element to the primitive cranium which is represented by the dura mater, and the
term extra-cranial should be applied to all tissues outside the dura mater. Early in
embryological life the dura mater and skin are in contact; gradually the base and
portions of the side wall of the membranous cranium chondrify, thus separating
the skin from the dura mater. In the vault of the skull, bone developes between
the dura mater and its cutaneous cap, but the skin and dura mater remain in
contact along the various sutures even for a year or more after birth. This relation
persists longest in the region of the anterior fontanelle and the neighbourhood of
the inion. Should the skin be imperfectly separated, or a portion remain
persistently adherent to the dura mater, it would act precisely as a tumour germ
and give rise to a dermoid. Such a tumour may retain its original attachment to
the dura mater, and its pedicle become surrounded by bone; the dermoid would lie
outside the bone but be lodged in a depression on the surface, with an aperture
transmitting its pedicle. On the other hand, the tumour may become separated
from the skin by bone; it would then project on the inner surface or between the
layers of the dura mater. If this view of the origin of dermoids be accepted, we
must modify our teaching and say that the depressions in which dermoids of the
cranium are lodged arise as imperfections in the developmental process, and are
not due to absorption induced by pressure; further, the fibrous connexion of such
dermoids with the dura mater is primary, not accidental.’[12]

Treatment. When of inconsiderable size, and when intracranial


connexions are absent, of doubtful existence, or of slight extent, the
sooner the tumour is removed the better. The dura mater should not
be opened unless absolutely necessary, in which case it should be
carefully sewn up and the scalp-flap replaced without drainage.
When possessing deep and extensive connexions, careful
dissection may still allow of the complete removal of the dermoid. It
is impossible to foretell with certainty whether it is possible to
remove the tumour until its basal portion is exposed. The operation
may be a formidable one.
Some points in the differential diagnosis between
Cephaloceles, Dermoids, and Cephalhæmatomata
Cephaloceles (congenital). Dermoids. Cephalhæmatomata.
Present at birth. Present at birth. Usually appears after
birth.
In middle line, especially In middle line, especially Always to one side of the
over occiput and base over anterior fontanelle. middle line, and usually
of nose. over the parietal bone.
Firm or fluctuating. Firm. Fluctuation over central
part only.
Perhaps translucent. Not translucent. Not translucent.
Perhaps pulsates. Does not pulsate. Does not pulsate.
Perhaps reducible, in Irreducible. Very slightly, if at all.
whole or in part.
Perhaps swells up on No alteration. Very slightly, if at all.
straining.
Perhaps associated with No cerebral symptoms. No cerebral symptoms.
cerebral symptoms.
Gap in skull felt. Depression in bone Deceptive raised margin,
common, actual gap no actual central
comparatively rare. depression.

HYDROCEPHALUS

The conditions that lead up to internal hydrocephalus are


classified by Parkes Weber[13] in the following manner:—
1. ‘Cases secondary to and part of the phenomena of
tuberculous or any suppurative meningitis, comparable to pleural
effusions due to tuberculous or any septic invasions of the pleura.
2. Cases resulting from the presence of tumours, &c., analogous
to the pleuritic effusions accompanying tumours, &c., situated close
to or involving the pleura.
3. Ordinary infantile or congenital hydrocephalus, which is, in
some cases at least, due to intra-uterine meningitis.
4. Internal hydrocephalus supervening on the epidemic or
sporadic type of posterior basic non-suppurative meningitis.
6. Simple idiopathic internal hydrocephalus of adults or older
children due to serous ependymitis or ventricular meningitis.
7. Traumatic cases.’
This classification possibly includes all the various grades and
degrees of internal hydrocephalus, but for all practical purposes the
cases may be grouped into two classes, congenital and acquired,
both of which may be either acute or chronic.
Congenital internal hydrocephalus. The condition may be
recognized soon after the birth of the child, or the enlargement of
the head may only become apparent some weeks or months later.
The slow development and the insidious nature of the enlargement,
as observed in many cases, may lead to some confusion between
the late congenital and the early acquired varieties. However, the
absence of any symptoms pointing to meningeal inflammation
between the time of the birth of the child and the hydrocephalic
development usually allows of correct classification.
It is doubtful whether congenital internal hydrocephalus can be
ascribed to malformation of the inter-ventricular channels and
occlusion of the passages by means of which the cerebro-spinal fluid
escapes into the cerebral subarachnoid space, or whether the
development is dependent on hypersecretion from the ependyma
and choroid plexuses. Virchow showed that occasionally there was
an actual formation of small grey-red masses, about the size of a
hemp-seed or cherry, in the walls of the ventricles, but other
authorities deny the existence of such changes, and consider that
the hydrocephalic condition is entirely dependent on congenital
malformation.
It would, however, seem more probable that we have to deal
with two distinct varieties of congenital internal hydrocephalus, one
resulting from intra-uterine ependymal inflammation (? syphilitic),
the other dependent on congenital malformations, especially in the
region of the fourth ventricle, where the foramina of Majendie, Key,
and Retzius are regarded as permitting the outward escape of the
fluid secreted from the lining membrane and choroid plexuses of the
ventricles.
Acquired hydrocephalus. Acquired hydrocephalus, whether
acute or chronic, presents certain antecedents or associations which
enable us to have a more clear idea as to the pathological conditions
present.
In the majority of cases it is secondary to basic meningitis
which, whether tuberculous or not, results in matting of membranes
and in the development of adhesions. The normal flow of cerebro-
spinal fluid from the ventricular to the cerebral subarachnoid spaces
is thus impeded.
Similar interference to the flow of cerebro-spinal fluid may be
caused by the growth of a tumour, especially those which originate
in the subtentorial region.
Progress of the case. Whether the progress of the case be
acute or chronic, the ultimate results are much the same. The fluid
in the ventricular spaces may be increased up to 1,000 c.c. or more,
pressure effects being exerted on the surrounding parts, with the
following results:—
A. The soft cerebral substance is slowly but surely compressed,
with the result that the sulci on the surface of the brain are more or
less obliterated, distinction between the white and grey matter may
be lost, the ventricular spaces are enormously dilated, and, in the
most marked cases, a mere shell of brain may intervene between
the ventricles and the surface of the brain.
This cerebral compression results in the development of two
main groups of symptoms, those referable to the general increase in
the intraventricular pressure and those due to regional compression.
The more general results are headache, vomiting, optic neuritis
and atrophy, slow pulse-rate, somnolence, and coma. The
temperature is variable, more commonly rising during the more
acute stages of the disease, and falling to normal or subnormal
during the quiescent periods.
Localizing features are to be found in squints, inequality of
pupils, retraction of the head and neck, dyspnœa, and dysphagia,
whilst compression of the cortical motor centres is evidenced by
twitchings, convulsions, and spasticity of the limbs. General
convulsions are by no means uncommon. Remissions and
intermissions of both local and general symptoms are frequently
observed, paralyses, for example, fluctuating in depth and character.
B. The bones comprising the vault of the skull become greatly
thinned and widely separated from one another, the fontanelles
enlarged, and the sutures unduly prominent. The head becomes
enlarged in all directions, and its increased weight renders the child
incapable of retaining postural control, the head being top-heavy
and falling about in all directions.
The bones of the base share in the deformity. The pressure
exerted on the orbital plates of the frontal bone force the globe in
the downward direction in such a manner that the infra-corneal
sclerotic is obscured by the lower lid, whilst the supra-corneal
portion is unduly prominent. The bony eminences in the region of
the sella turcica are diminished in size, the middle fossa of the skull
flattened from side to side, and the posterior fossa from before
backwards. In such cases the skull assumes an almost dolicocephalic
appearance. In any case, the disproportion between the enlarged
skull and diminutive face is a marked feature.[14]
The scalp becomes stretched, hairs are sparse and brittle, and
the veins dilated.
Treatment. Indications for operation. The results obtained by
operation for internal hydrocephalus are not sufficiently encouraging
to enable the surgeon to urge immediate operative treatment.[15]
Still, it is perfectly clear that he cannot possibly carry out surgical
treatment with benefit to the patient if the ventricular distension is
allowed to progress to such a degree that marked cortical flattening
and degeneration occurs. No fixed probationary period can be laid
down as a guide, each case must be judged on its own merits.
Special attention should be paid, however, to the disks and lower
extremities. Any suggestion of optic neuritis or spasticity should be
regarded as urgently demanding operative interference.
Lumbar puncture cannot be expected to confer other than
temporary benefit even under the most favourable circumstances,
whilst, in the event of interference in the normal communication
between the ventricular and cerebro-spinal spaces, no relief can be
anticipated. Connal recommends that lumbar puncture should be
carried out daily, or twice daily, over extended periods of time. This
operation, however, is by no means devoid of danger, and the results
obtained by such treatment are not at all satisfactory.
Operation. Operations are carried out (a) with the object of
withdrawing fluid from the distended ventricular cavities (ventricular
puncture), and (b) to establish a communication, or short-circuit,
between the ventricular space and other spaces (ventricular
drainage).
Ventricular puncture. This operation may be carried out through
the anterior fontanelle, through the frontal bone, or over the
descending cornu of the lateral ventricle.
Through the anterior fontanelle. The region of the fontanelle is
shaved and cleansed in the usual manner, after which the
surrounding parts are cut off from the field of operation by a large
sheet of gauze or lint, in which a hole is cut sufficing to allow of
exposure of the site of election for puncture.
The patient should be in the recumbent position, the head well
towards the end of the table. The operation is performed without an
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