Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Nokigiri Web
Search
Leslie Zhao
May 25, 2016
Technology
0
79
Nokigiri Web
Nokigiri as a Ruby scrawler
Leslie Zhao
May 25, 2016
Tweet
Share
More Decks by Leslie Zhao
See All by Leslie Zhao
Rails实时web开发
geekontheway
0
48
Other Decks in Technology
See All in Technology
オブジェクト指向宗教史
tanakahisateru
13
12k
単回帰分析について数式を追いながら実装してみた
kentaitakura
0
500
Kubeflow Pipelines v2 で変わる機械学習パイプライン開発
asei
4
340
Evolutionary Optimization of Model Merging Recipes
fuyu_quant0
3
520
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
7
100k
サービス成長と共に肥大化するモノレポ、長くなるCI時間 / As services grow, monorepos get bigger and CI time gets longer
kohbis
5
2.1k
生成AIの不確実性と向き合うためのオブジェクト指向設計
tkikuchi1002
2
660
KubeCon EU 2024 : Knative Maintainers Session
salaboy
0
370
Challenges - Open Farming Hackdays 2024
loleg
0
560
継続的テストモデルを実現するためにスリーアミーゴスを用いた10Xでのシフトレフトの事例
nihonbuson
3
160
ビジネスとコード品質の接合点 そしてコード品質がそこに及ぼす影響 / The Intersections of Business and Engineering, and The Impact of Code Quality There
mtx2s
10
1k
任意コード実行の原理
ffri
0
170
Featured
See All Featured
Music & Morning Musume
bryan
39
5.5k
Statistics for Hackers
jakevdp
789
220k
[RailsConf 2023] Rails as a piece of cake
palkan
21
3.8k
Git: the NoSQL Database
bkeepers
PRO
421
63k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Principles of Awesome APIs and How to Build Them.
keavy
119
16k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
18
1.7k
Fashionably flexible responsive web design (full day workshop)
malarkey
397
65k
Web Components: a chance to create the future
zenorocha
304
41k
Fireside Chat
paigeccino
19
2.6k
BBQ
matthewcrist
78
8.7k
Happy Clients
brianwarren
91
6.3k
Transcript
Nokogiri Web 解析 不是爬⾍虫
What Covers • 想法:从搜索到落地 • Demo: ⽰示例抓取演⽰示 • 解决⽅方案:异步⻚页⾯面的抓取 •
脑洞⼤大开:探索可以做的好玩事情 • 不包括:基础的代码语法
• 从指定⺴⽹网站提取数据,⽐比如电商⺴⽹网站的定价数据, ⾖豆瓣的电影书籍评分,美图⺴⽹网站的照⽚片,⼩小说⺴⽹网 站的最新章节 • 从本地或远程⽂文件中提取数据,获得分析结果 • 爬取别⼈人⺴⽹网站,需要先分析别⼈人⺴⽹网站的内容,从 ⽽而学习⼀一定的前端知识,有些⺴⽹网站的前端直接调 ⽤用的是裸接⼝口,通过分析前端⻚页⾯面,可以获得接
⼝口地址,快速干净的批量获取到我们需要的数据 Why…
Then… • 抓取数据之后,可以导出成json或保存在数据库 中,如果数据有价值,可以做成⺴⽹网站⼩小范围分享, 或者⾃自⼰己私有的RSS, 常⻅见:公众号聚合,⼩小说下 载,图⽚片分享,电商推荐 • 监控⾃自有⺴⽹网站服务状态 •
监控对⼿手⺴⽹网站服务更新 • 为⾃自⼰己的⺴⽹网站加⼊入更多属性:评分,⽐比价...
关键字
None
None
None
Nokogiri 只是⼀一个⺴⽹网⻚页解析组件,可以⽤用来实验, 不适合做爬⾍虫,可选择java或python更好 的解决⽅方案
“Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser.
Among Nokogiri's many features is the ability to search documents via XPath or CSS3 selectors.”
CSS Selector #product_list > div:nth-child(1) > a > img
XPath Selector //*[@id="product_list"]/div[1]/a/img
None
Examples
http://www.wowebook.pw/
http://www.thebeastshop.com/item/detail/S00301000013765.htm
异步⻚页⾯面的抓取使⽤用 watir-webdriver https://paddle8.com/artworks/all:popular
脑洞⼤大开 真实的抓取可能遇到 1.request ip limit 2.request cookie limit 3.request behaviour
detect 4.user account authenticate