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
Introduction for Brownant
Jiangge Zhang
April 11, 2014
Other Decks in Programming
See All in Programming
LLM Plugin for Node-REDの利用方法と開発について
404background
0
150
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
1
690
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
710
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
310
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
170
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
240
Moments When Things Go Wrong
aurimas
3
140
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
440
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
470
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
190
OCRを使ってゲームのアイテムをデータ化する
kishikawakatsumi
0
130
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
430
Featured
See All Featured
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
320
A Modern Web Designer's Workflow
chriscoyier
698
190k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
560
Rails Girls Zürich Keynote
gr2m
96
14k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
480
The Curse of the Amulet
leimatthew05
1
13k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
A designer walks into a library…
pauljervisheath
211
24k
Odyssey Design
rkendrick25
PRO
2
670
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
260
ラッコキーワード サービス紹介資料
rakko
1
3.5M
The agentic SEO stack - context over prompts
schlessera
0
790
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~❤️