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
4
160
Introduction for Brownant
Jiangge Zhang
April 11, 2014
Tweet
Share
Other Decks in Programming
See All in Programming
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
290
New in Go 1.26 Implementing go fix in product development
sunecosuri
0
330
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
1k
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
230
The Ralph Wiggum Loop: First Principles of Autonomous Development
sembayui
0
3.7k
CSC307 Lecture 13
javiergs
PRO
0
310
Agent Skills Workshop - AIへの頼み方を仕組み化する
gotalab555
14
7.9k
AHC061解説
shun_pi
0
320
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
200
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
200
15年目のiOSアプリを1から作り直す技術
teakun
1
600
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
110
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.8k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
490
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
96
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
110
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
240
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
380
Building the Perfect Custom Keyboard
takai
2
710
How to build a perfect <img>
jonoalderson
1
5.2k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
The Curse of the Amulet
leimatthew05
1
9.6k
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~❤️