Web Scraping
Python で書かれた Web Scraping フレームワークのをちらっと見てみた。
特徴は、
Automatic cookies (session) support
HTTP and SOCKS proxy with and without authorization
Keep-Alive support
IDN support
Tools to work with web forms
Easy multipart file uploading
Flexible customization of HTTP requests
Automatic charset detection
Powerful API of extracting info from HTML documents with XPATH queries
Asynchronous API to make thousands of simultaneous queries. This part of library called Spider and it is too big to even list its features in this README.
Python 3 ready
ということで、なんか便利そうな感じがするので見てみる。依存関係があるのは、
- lxml
- pycurl
- selection
- weblib
- six
インストールは、
pip istall -U lxml pycurl selection weblib six
pip install -U Grab
サイトにあるサンプルはこんな感じ。
from grab import Grab
g = Grab()
g.go('https://github.com/login')
g.set_input('login', 'lorien')
g.set_input('password', '***')
g.submit()
for elem in g.doc.select('//ul[@id="repo_listing"]/li/a'):
print('%s: %s' % (elem.text(), elem.attr('href')))
ログインしてから、ちょっとなにか取ってくるというのが簡単に書ける。
忙しいのが一段落したら、この手のものは、あれこれあると思うので、比較しながらちょっと使ってみようかな。
忘備録用に Hatena Blog をはじめた
MacBook Air を買った。覚えきれないこともたくさんあるので、記録用にブログを作って書き込んでおくことにした。とりあえず、Python の環境を作ろうとして作業し始める。
brew であれこれインストールすればいいのかと、やり始めたが、brew bundle とか使っているのを見つけたが、今は使えないみたい。十分な予備知識がない状態で新しく使い始めた環境だと、何が正解かなかなか分からないが、とりあえず、目に付いたこのあたり参考にして環境を作る。
このあたりも参考にした。
wxPython については、これを参考にした。
Tips 系は Qiita がけっこう役立つかな。
とりあえず Python が使える環境ができた。