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
170
4
Share
Introduction for Brownant
Jiangge Zhang
April 11, 2014
Other Decks in Programming
See All in Programming
開発とはなにか、Essenceカーネルで見えるもの
ukin0k0
0
210
Zod v4 Codec でスキーマに型変換を埋め込む REST API 設計 #TSKaigi2026
ryutaro_yako
0
150
GitHub Copilot CLIのいいところ
htkym
2
1.1k
~ 秘伝のタレ化した『神スプシ』と戦う ~ 関数型パラダイムで壊れない仕組みへ
h0r15h0
1
130
誰も頼んでない機能を出荷した話
zekutax
0
140
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
240
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
240
New "Type" system on PicoRuby
pocke
1
210
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.2k
今さら聞けないCancellationToken
htkym
0
200
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
380
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
1.7k
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
210
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
380
How to Talk to Developers About Accessibility
jct
2
210
How to train your dragon (web standard)
notwaldorf
97
6.6k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Writing Fast Ruby
sferik
630
63k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
Building Adaptive Systems
keathley
44
3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
190
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~❤️