LoginSignup
8
7

More than 5 years have passed since last update.

[python] lassieでWebページのメタデータをサクっととってくる

Last updated at Posted at 2013-08-08

こんにちは。最近暑いですね。暑くなるとページ巡回して要素を抽出するのもうんざりします。ここはpythonのlassieを使ってさっさと済ませちゃいましょう。

lassie

Web Content Retrieval for Humans™

だそうです

installation

pip install lassie

pipからいけます

usage

>> import lassie
>> fetched = lassie.fetch('http://www.youtube.com/watch?v=tkjbEqnp_0U')

こんだけ。

中身はこんな感じ。

>> from pprint import pprint
>> pprint(fetched)

{'description': u'Recording of the July 12, 2013 webcast,   "What\'s New in Riak 1.4"',
 'images': [{'src': u'http://b.vimeocdn.com/ts/ 445/011/445011693_640.jpg',
             'type': u'og:image'}],
 'title': u"What's New in Riak 1.4",
 'url': u'http://vimeo.com/71448923',
 'videos': [{'height': 400,
         'src': u'http://vimeo.com/moogaloop.swf?clip_id=71448923',
         'type': u'application/x-shockwave-flash',
         'width': 640},
        {'height': 400,
         'src': u'https://player.vimeo.com/video/71448923',
         'width': 640}]}

タイトル、説明、(ここでは出てないけど)キーワード、画像、ビデオ等を抜き出して返してくれます。サムネ候補もタイプ付きで返してくれるのが心憎いですね。

暑い夏も穏やかに過ごせそうです。

dependencies

setup.py

    install_requires=[
    'requests==1.2.3',
    'beautifulsoup4==4.2.1',
    'html5lib==1.0b3'
    ],

おなじみですね。

lassie

【名詞】【可算名詞】《スコットランド方言》 娘,少女; お嬢さん (⇔laddie).
[LASS+‐IE]

lassieの意味 - 英和辞典 Weblio辞書

なるほど

えっとひょっとして

名犬ラッシー

「Lassie」は、英語では、「お嬢さん・少女」の意味の愛称的な言葉で、当然ラッシーは雌のコリーである。

名犬ラッシー - Wikipedia

知りませんでした。勉強になりますね。

8
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7