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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
160
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
200
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
310
ふん…おもしれぇ Parser。RubyKaigi 行ってやるぜ
aki_pin0
0
100
ご飯食べながらエージェントが開発できる。そう、Agentic Engineeringならね。
yokomachi
1
110
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
120
AI時代の認知負荷との向き合い方
optfit
0
180
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
260
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.4k
2026/02/04 AIキャラクター人格の実装論 口 調の模倣から、コンテキスト制御による 『思想』と『行動』の創発へ
sr2mg4
0
470
Sekiban + Microsoft Orleans のアクターをAWS対応しました / Sekiban + Microsoft Orleans actors are now supported on AWS.
tomohisa
0
110
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
120
Featured
See All Featured
Docker and Python
trallard
47
3.7k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Designing for Performance
lara
611
70k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
58
Are puppies a ranking factor?
jonoalderson
1
3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
First, design no harm
axbom
PRO
2
1.1k
For a Future-Friendly Web
brad_frost
182
10k
Mind Mapping
helmedeiros
PRO
1
93
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~❤️