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
AI活用のコスパを最大化する方法
ochtum
0
130
TipKitTips
ktcryomm
0
160
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
200
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
3
1.1k
encoding/json/v2のUnmarshalはこう変わった:内部実装で見る設計改善
kurakura0916
0
350
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
750
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
200
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
370
AIプロダクト時代のQAエンジニアに求められること
imtnd
2
750
PJのドキュメントを全部Git管理にしたら、一番喜んだのはAIだった
nanaism
0
240
CSC307 Lecture 15
javiergs
PRO
0
230
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
130
Featured
See All Featured
The Invisible Side of Design
smashingmag
302
51k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
81
The Cult of Friendly URLs
andyhume
79
6.8k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Technical Leadership for Architectural Decision Making
baasie
3
280
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
170
Paper Plane
katiecoart
PRO
0
47k
A designer walks into a library…
pauljervisheath
210
24k
Building AI with AI
inesmontani
PRO
1
770
Six Lessons from altMBA
skipperchong
29
4.2k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
61
52k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
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~❤️