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
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
Implementation Patterns
denyspoltorak
0
270
Data-Centric Kaggle
isax1015
2
710
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
520
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.2k
CSC307 Lecture 03
javiergs
PRO
1
480
AIエージェントの設計で注意するべきポイント6選
har1101
7
3.3k
gunshi
kazupon
1
140
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
5.8k
ゆくKotlin くるRust
exoego
1
210
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
170
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
260
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
5.9k
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
46
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Visualization
eitanlees
150
16k
Test your architecture with Archunit
thirion
1
2.1k
Leo the Paperboy
mayatellez
4
1.3k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Ethics towards AI in product and experience design
skipperchong
2
180
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
75
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.4k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
36k
A better future with KSS
kneath
240
18k
Raft: Consensus for Rubyists
vanstee
141
7.3k
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~❤️