Skip to Content
PythonによるWebスクレイピング 第3版
book

PythonによるWebスクレイピング 第3版

by Ryan Mitchell, 嶋田 健志, 新井 翔太
June 2025
Intermediate to advanced
356 pages
5h 13m
Japanese
O'Reilly Japan, Inc.
Content preview from PythonによるWebスクレイピング 第3版

18章スクレイパーによるWebサイトのテスト

大規模な開発スタックを伴うWebプロジェクトに携わっていると、定期的にテストされるのはスタックの「バックエンド」部分だけということがよくあります。現代の主要なプログラミング言語(Pythonを含む)には何らかのテストフレームワークが備えられていますが、ユーザーにとってインターフェースとなるWebサイトのフロントエンドは、こうした自動テストの対象から外されがちです。

この問題の一因として、Webサイトが多様なマークアップ言語やプログラミング言語で構成されている、という点があります。JavaScriptの特定部分に対してユニットテストを書いても、連携するHTML側が変更されていて、JavaScriptがページで期待していた動作が変わってしまうと、JavaScript自体が正しく動いていても意味がありません。

フロントエンドのWebサイトをテストするという課題は、軽視されがちであったり、チェックリストやバグトラッカーを使う程度の下位レイヤーのプログラマーに任されたりすることが多いのが現状です。とはいえ、少しの手間をかけるだけで、これらのチェックリストをユニットテストに置き換え、人間の目視検証をWebスクレイパーに置き換えることができます。

Web開発におけるテストを活用した開発を想像してみてください。Webインターフェースのすべての機能が想定通りに動いているかを日次で確認するリグレッションテストです。新しい機能を追加したり、要素の配置を変えたりするたびに、自動テストが実行されます。本章では、テストの基本的な考え方と、シンプルなサイトから複雑なサイトに至るまで、PythonベースのWebスクレイパーを使ってあらゆるWebサイトをテストする方法を解説します。 ...

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

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

初めてのSQL 第3版

初めてのSQL 第3版

Alan Beaulieu, 株式会社クイープ
scikit-learn、Keras、TensorFlowによる実践機械学習 第3版

scikit-learn、Keras、TensorFlowによる実践機械学習 第3版

Aurélien Géron, 下田 倫大, 牧 允皓, 長尾 高弘

Publisher Resources

ISBN: 9784814401222Publisher Website