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
S3ストレージクラスの「見える」「ある」「使える」は全部違う ─ 体験から見た、仕様の深淵を覗く
ya_ma23
0
1.1k
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
190
モダンOBSプラグイン開発
umireon
0
180
Linux Kernelの1文字のミスで 権限昇格ができた話
rqda
0
2.2k
Symfony + NelmioApiDocBundle を使った スキーマ駆動開発 / Schema Driven Development with NelmioApiDocBundle
okashoi
0
240
CSC307 Lecture 15
javiergs
PRO
0
270
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
590
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.4k
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
2
410
Angular-Apps smarter machen mit Gen AI: Lokal und offlinefähig - Hands-on Workshop!
christianliebel
PRO
0
140
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
7
3.2k
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
3
420
Featured
See All Featured
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
980
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
690
The SEO identity crisis: Don't let AI make you average
varn
0
420
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.4k
Abbi's Birthday
coloredviolet
2
5.8k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
250
SEO for Brand Visibility & Recognition
aleyda
0
4.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Designing for Timeless Needs
cassininazir
0
170
A better future with KSS
kneath
240
18k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
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~❤️