Python Web Scraping in Practice (2nd Edition) cover

Python Web Scraping in Practice (2nd Edition)

Rating 3.4
Word count
630 words
Chapters
11
ISBN
9787302510086

Tags

Summary

More than one book is titled "Web Scraping in Practice," and Hu Songtao's is the most widely circulated: first published in 2017, with a second edition in 2018 still in use, from Tsinghua University Press, and held by many university libraries across China. Its strengths are clear: it does not aim for theoretical completeness but walks through the most practical path—set up the environment, write small scripts, and pick a suitable scraping tool to accomplish one task. The most commendable change in the second edition is the full move to Python 3. The first edition used Python 2.7 and drew many complaints; the revision not only converts the code to Python 3 but adds Pyspider and an anti-scraping chapter, expanding from 294 to 381 pages. The first four chapters cover syntax and debugging, then warm up with small examples such as a multiplication table and multithreading, making it relatively friendly to readers without a programming background. From Chapter 5, the book adopts a contrastive "one need, one tool" approach: Scrapy for large data volumes, Beautiful Soup for simple page structures, Mechanize for logins, Selenium for JS rendering, and Pyspider for a graphical interface. This classification helps beginners quickly judge which tool a task calls for—a practical perspective rare in comparable books; each case covers environment preparation, code writing, and line-by-line explanation, and can basically be typed through. Shortcomings should be noted upfront: dependencies such as PhantomJS, Mechanize, and Pyspider are now mostly unmaintained, and the example sites have long since been redesigned, so the code may not run as-is; a Douban rating of 6.7 (40 ratings) also reflects dissatisfaction with depth and currency. Treat it as an introductory reader on scraping workflows and a tool map, not a code manual to copy long-term—understanding the ideas and migrating to Requests, Playwright, or newer Scrapy will yield more.

Editor's review

市面上叫「网络爬虫实战」的书不止一本,胡松涛这一版是流传最广的一种:2017年初版,2018年推出第2版并沿用至今,清华大学出版社出版,全国多所高校图书馆在架。它的优点非常明确——不追求理论完备,而是把「装环境、写小脚本、挑一个合适的爬虫工具干一件事」这条最实用的路径走一遍。 第2版最值得肯定的一处改动是全面转向 Python 3。初版用 Python 2.7 讲解,曾招来不少读者抱怨;修订版不但把代码改成 Python 3,还补上了 Pyspider 和反爬虫章节,篇幅从294页扩到381页。前四章先讲语法和调试,再用九九乘法表、多线程之类的小例子热身,对没有编程基础的人相对友好。 从第5章开始,本书采用「一种需求对一个工具」的对照式写法:数据量大用 Scrapy,页面结构简单用 Beautiful Soup,要登录用 Mechanize,JS 渲染用 Selenium,想要图形界面用 Pyspider。这种分类方式能帮初学者快速判断手头任务该挑什么工具,是同类书里少见的实用视角;每个案例都从环境准备、代码编写讲到逐行解释,基本可以照着敲通。 不足之处也要提前说明:书中依赖的 PhantomJS、Mechanize、Pyspider 如今大多停止维护,示例站点也早已改版,代码未必能原样跑通;豆瓣评分6.7(40人评价)也反映出读者对深度和时效性的不满意。因此建议把它当「爬虫流程与工具地图」的入门读物,而不必当作可长期照抄的代码手册——理解思路后迁移到 Requests、Playwright、新版 Scrapy 上,收获会更大。

Who it's for

A good fit for

  • 零基础或刚学完 Python 语法、想找一个完整练手方向的自学者
  • 需要快速判断「什么任务用哪个爬虫工具」的初级开发者
  • 高校计算机、软件工程、数据科学专业开设爬虫课程的学生与教师
  • 做数据采集、需要了解模拟登录与反爬应对思路的数据分析从业者

Not a good fit for

  • 已有多年爬虫经验、希望学习分布式、异步高性能架构的资深工程师
  • 只想复制可直接上线代码、不愿自行调试和更新依赖的读者
  • 完全没接触过 Python、需要系统语法教材的纯零基础读者

Reading tips

  1. 先按第1、2章把 Python 3 环境和 pip 装好,亲手跑通 hello world 再往下读,不要跳过环境配置。
  2. 第3章的小脚本建议全部手敲一遍,比复制粘贴更能建立语法和调试手感。
  3. 读第5至9章时,按自己的目标站点选一个工具深入实践,不必五种全学,其余快速浏览作对照。
  4. 遇到 PhantomJS、Pyspider 等已停止维护的依赖,优先把思路迁移到 Playwright 或新版 Scrapy,并补充阅读目标网站的使用条款与 robots 协议。

About the publisher

Tsinghua University Press China · Founded in 1980

Founded in 1980, Tsinghua University Press has 57 titles in our collection, covering popular science, medicine, health, law, philosophy and social sciences. Representative works include medical popular-science books such as Cancer Truth: Doctors Are Reading It Too and New Knowledge on Cancer by Bo Luo (Li Zhizhong), legal titles such as Sunshine Is the Best Preservative: Express Delivery of Major Global Anti-Corruption Cases, and works like Qi Ge's A Brief History of Philosophy with Big Ideas and Liu Yunhao's From the Internet to a New Industrial Revolution. Its authors include science writers, medical researchers, the Renmin University of China anti-corruption master's class and university scholars, reflecting a publishing profile that balances academic seriousness with accessible reading. As public information is limited, this profile is based only on the titles in our collection.

Contents

  1. Chapter 1 Configuring the Python Environment
  2. Chapter 2 Python Fundamentals
  3. Chapter 3 Simple Python Scripts
  4. Chapter 4 Common Modules for Python Scrapers
  5. Chapter 5 The Scrapy Framework
  6. Chapter 6 Beautiful Soup Scrapers
  7. Chapter 7 Simulating Browsers with Mechanize
  8. Chapter 8 Simulating Browsers with Selenium
  9. Chapter 9 The Pyspider Framework
  10. Chapter 10 Scrapers and Anti-Scraping
  11. About the Author

FAQ

这本书第2版和第1版有什么区别?
第1版2017年出版、8章294页,代码用 Python 2.7;2018年第2版全书10章381页,基于 Python 3.6.4,把能迁移的爬虫全部改写为 Python 3,并新增 Pyspider 爬虫框架与「爬虫与反爬虫」两章,建议直接读第2版。
同名书有好几本,该怎么区分?
清华大学出版社至少出过三本同名书:胡松涛版(ISBN 9787302457879,2018年第2版为9787302510086)、吕云翔与张扬版(ISBN 9787302515920,14章),以及胡松涛2020年的《Python3网络爬虫实战》。本书是胡松涛的10章第2版。
零基础能看懂这本书吗?
大致可以。前四章覆盖环境配置、变量、语句、函数与类、调试,并配有小脚本,对零基础读者友好;但讲解偏简略,若完全没写过代码,建议同时用一份系统的 Python 教程打底,再回来看爬虫部分。
书里的代码现在还能跑通吗?
不一定。书中使用的 PhantomJS、Mechanize、Pyspider 多数已停止维护,示例站点也早已改版,原样运行很可能报错。建议把书当思路和流程参考,将代码迁移到 Requests、Playwright、新版 Scrapy 等当前工具上。
豆瓣评分只有6.7,值得买吗?
评分样本小(约40人评价),主要争议是时效性和深度。如果你需要一本结构清晰、按工具分类讲解的爬虫入门书,理解流程后自行更新代码,它仍有参考价值;若想要最新最佳实践,建议搭配近年出版的爬虫书一起看。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

胡松涛 Author

Hu Songtao is an author about whom limited public information is available; the existing records show only one work by him, Leizu. The book is classified under the category of otherworldly continents, indicating that his writing leans toward fantasy and unfolds against a fictional, non-realistic world. Such fiction usually involves world settings, group relations, and adventure threads different from those of the real world, while the title Leizu borrows the name of a figure from ancient Chinese legend, giving the work a certain traditional cultural flavor within a fantasy framework. Because reliable records of Hu Songtao's life, writing career, and other works are currently lacking, no fuller judgment can be made about how his style took shape or about his overall output. Judging from this single work in the database, the author seems inclined to combine native legendary elements with the otherworldly fantasy genre, and readers interested in such themes may take Leizu as an entry point for understanding his writing orientation.

More by the same author

Top rated in the same category