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
ThorVG Viewer In VS Code
nors
0
500
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
230
SwiftUIで本格音ゲー実装してみた
hypebeans
0
550
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
330
CSC307 Lecture 02
javiergs
PRO
1
710
AI時代を生き抜く 新卒エンジニアの生きる道
coconala_engineer
1
490
Denoのセキュリティに関する仕組みの紹介 (toranoana.deno #23)
uki00a
0
200
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
540
Grafana:建立系統全知視角的捷徑
blueswen
0
260
Navigating Dependency Injection with Metro
l2hyunwoo
1
200
SQL Server 2025 LT
odashinsuke
0
120
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
430
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
990
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
51k
The Invisible Side of Design
smashingmag
302
51k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
89
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.4k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
0
980
Between Models and Reality
mayunak
1
150
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
99
Applied NLP in the Age of Generative AI
inesmontani
PRO
3
2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
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~❤️