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
4
160
Introduction for Brownant
Jiangge Zhang
April 11, 2014
Tweet
Share
Other Decks in Programming
See All in Programming
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
200
2026年 エンジニアリング自己学習法
yumechi
0
110
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
160
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.2k
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
350
rack-attack gemによるリクエスト制限の失敗と学び
pndcat
0
260
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
130
Denoのセキュリティに関する仕組みの紹介 (toranoana.deno #23)
uki00a
0
260
CSC307 Lecture 01
javiergs
PRO
0
680
AIエージェントの設計で注意するべきポイント6選
har1101
7
3.3k
CSC307 Lecture 04
javiergs
PRO
0
650
Fluid Templating in TYPO3 14
s2b
0
110
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
100
6k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.6k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
420
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1.1k
Music & Morning Musume
bryan
47
7k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
120
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Rails Girls Zürich Keynote
gr2m
96
14k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
A Soul's Torment
seathinner
5
2.2k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
900
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~❤️