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
Introduction for Brownant
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Jiangge Zhang
April 11, 2014
Programming
180
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction for Brownant
Jiangge Zhang
April 11, 2014
Other Decks in Programming
See All in Programming
AIで効率化できた業務・日常
ochtum
0
130
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
180
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4k
Agentic UI
manfredsteyer
PRO
0
160
スマートグラスで並列バイブコーディング
hyshu
0
140
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
110
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.6k
The NotImplementedError Problem in Ruby
koic
1
790
Webフレームワークの ベンチマークについて
yusukebe
0
170
Oxcを導入して開発体験が向上した話
yug1224
4
310
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
130
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
680
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
810
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
430
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Utilizing Notion as your number one productivity tool
mfonobong
4
320
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
250
Claude Code のすすめ
schroneko
67
230k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Site-Speed That Sticks
csswizardry
13
1.2k
The Curse of the Amulet
leimatthew05
1
13k
Transcript
(´ŋ_ŋ`)
贴⼀一个 URL,得到数据 “抓”
需要结构化的数据 • ⽤用统计学⽅方法猜测 —— Readability、Pocket、搜索引擎 • ⽤用约定的协议(如 schema.org、OpenGraph) —— Facebook、Twitter
Card、搜索引擎 • 抓取者定制规则 —— ⾖豆瓣东⻄西
⽐比较笨的实现 写⼀一个函数去匹配和分解 URL
⽐比较笨的实现 ⼜又写⼀一个函数去抽取信息
其实⼤大部分规则 都是可以 ⽤用配置⽂文件写出来的
配置⽂文件就是这样 。。。。。。
静态配置的问题 • 原来 title_pattern = `//*[@id=info]/h2/text()` • 后来这个⺴⽹网站改版了,需要请求另⼀一个 API 才能拿
到标题 • 我们就 。。。。。。
如果需要能伸能缩 DSL
最好的例⼦子 DSL with Ruby
既是语⾔言,也是配置
Brownant 基于 Python 的 descriptor 特性
Python 的 descriptor • 拦截 getattr、setattr、delattr • 能访问宿主对象 • “元属性”
None
Pipeline o.title o.etree o.text_response o.http_client o.url
Pipeline o.title o.etree o.text_response o.http_client o.ajax_response o.ajax_json o.price o.url o.ajax_url
借助了其他开源库 • Werkzeug —— URL 分发 • lxml 和 requests
—— 访问⺴⽹网络、解析 HTML • six —— 兼容 Python 2 / Python 3
接下来希望解决的问题 • ⽂文档太简陋 • 内置 PipelineProperty 类型太少 • 不会画蚂蚁,所以没 Logo
github.com:douban/brownant Waiting your pull request tonight~❤️