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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
380
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
0
190
Inside Stream API
skrb
1
220
分析エージェント精度向上における データアナリストの役割
oura_shoya
0
120
iOS26時代の新規アプリ開発
yuukiw00w
0
200
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
240
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
280
AIとRubyの静的型付け
ukin0k0
0
130
~ 秘伝のタレ化した『神スプシ』と戦う ~ 関数型パラダイムで壊れない仕組みへ
h0r15h0
1
130
Claspは野良GASの夢をみるか
takter00
0
130
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3k
inferと仲良くなる10分間
ryokatsuse
1
260
Featured
See All Featured
First, design no harm
axbom
PRO
2
1.2k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
370
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
190
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
360
The Invisible Side of Design
smashingmag
302
52k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
270
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
140
How to build a perfect <img>
jonoalderson
1
5.5k
Paper Plane
katiecoart
PRO
1
50k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
360
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
290
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~❤️