

Python爬虫编程思想(36):项目实战-抓取斗破小说网的目录和全文
source link: https://blog.csdn.net/nokiaguy/article/details/120541383
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python爬虫编程思想(36):项目实战-抓取斗破小说网的目录和全文
到现在为止我们已经学习了3个Python网络库(urllib、urllib3和requests),以及通过正则表达式过滤字符串。现在该来点实战了。本节以及后面2节会给出3个案例,分别使用urllib、urllib3以及requests,并通过正则表达式抓取Web数据,这些数据或者显示在Console中,或者保存到文本文件中。
本文要实现的案例是通过urllib库抓取斗破小说网(http://www.doupoxs.com)上指定的小说的目录和每一节的完整内容(只保留纯文本内容)。当抓取包含目录和小说内容的页面后,会通过正则表达式分析HTML代码,并提取出目录标题、对应的URL以及文本形式的小说内容。
现在进入斗破小说网,选择一篇小说,本节选择了http://www.doupoxs.com/nalanwudi,目录页面如图1所示。
Recommend
-
9
Python爬虫编程思想(38):项目实战:抓取糗事百科网的段子 ...
-
3
Python爬虫编程思想(37):项目实战:抓取猫眼电影Top100榜单 ...
-
13
Python爬虫编程思想(47):项目实战:抓取豆瓣Top250图书榜单 ...
-
9
Python爬虫编程思想(48):项目实战:抓取起点中文网的小说信息 ...
-
6
Python爬虫编程思想(61): 项目实战:抓取租房信息 ...
-
8
Python爬虫编程思想(62): 项目实战:抓取酷狗网络红歌榜 ...
-
7
Python爬虫编程思想(69): 项目实战--抓取当当图书排行榜 ...
-
4
Python爬虫编程思想(86):项目实战--抓取豆瓣音乐排行榜 ...
-
11
Python爬虫编程思想(103):项目实战--抓取QQ空间说说的内容 ...
-
8
Python爬虫编程思想(114):项目实战--使用Splash Lua抓取京东搜索结果 ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK