2012/02/09

Recent entries from same category

  1. Lingr Radar For Linuxってのを書いた
  2. デスクトップアプリケーションでも認証可能なOAuth「xAuth」をpythonから試してみた。
  3. Mumblesを使ったGitHubのGrowl通知アプリケーションを作った。
  4. Python2.6にはcursesのバイナリが含まれていないので作る
  5. Google App Engineでアプリを高速化する3つのtips

たとえばこういう XML があったとして、
<status><created_at>Mon Feb 06 21:07:52 +0000 2012</created_at><id>166629198054690816</id><text>Post-Bowl Twitter analysis http://t.co/OYYSRSew http://t.co/M0AtLQVd</text><source>web</source><truncated>false</truncated><favorited>false</favorited><in_reply_to_status_id></in_reply_to_status_id><in_reply_to_user_id></in_reply_to_user_id><in_reply_to_screen_name></in_reply_to_screen_name><retweet_count>454</retweet_count><retweeted>false</retweeted><user><id>783214</id><name>Twitter</name><screen_name>twitter</screen_name><location>San Francisco, CA</location><description>Always wondering what's happening. </description><profile_image_url>http://a0.twimg.com/profile_images/1124040897/at-twitter_normal.png</profile_image_url><profile_image_url_https>https://si0.twimg.com/profile_images/1124040897/at-twitter_normal.png</profile_image_url_https><url>http://blog.twitter.com/</url><protected>false</protected><followers_count>7625563</followers_count><profile_background_color>ACDED6</profile_background_color><profile_text_color>333333</profile_text_color><profile_link_color>038543</profile_link_color><profile_sidebar_fill_color>F6F6F6</profile_sidebar_fill_color><profile_sidebar_border_color>EEEEEE</profile_sidebar_border_color><friends_count>822</friends_count><created_at>Tue Feb 20 14:35:54 +0000 2007</created_at><favourites_count>16</favourites_count><utc_offset>-28800</utc_offset><time_zone>Pacific Time (US &amp; Canada)</time_zone><profile_background_image_url>http://a1.twimg.com/profile_background_images/378245879/Twitter_1544x2000.png</profile_background_image_url><profile_background_image_url_https>https://si0.twimg.com/profile_background_images/378245879/Twitter_1544x2000.png</profile_background_image_url_https><profile_background_tile>true</profile_background_tile><profile_use_background_image>true</profile_use_background_image><notifications>false</notifications><geo_enabled>true</geo_enabled><verified>true</verified><following>true</following><statuses_count>1266</statuses_count><lang>en</lang><contributors_enabled>true</contributors_enabled><follow_request_sent>false</follow_request_sent><listed_count>68708</listed_count><show_all_inline_media>true</show_all_inline_media><default_profile>false</default_profile><default_profile_image>false</default_profile_image><is_translator>false</is_translator></user><geo/><coordinates/><place/><possibly_sensitive>false</possibly_sensitive><contributors><user_id>7694352</user_id></contributors></status>
見づらいので vimrc に1行書いてあげると、 map <Leader>x !python -m BeautifulSoup<CR>
範囲選択してから <Leader> x でキレイに整形してくれます。 <status>
 <created_at>
  Mon Feb 06 21:07:52 +0000 2012
 </created_at>
 <id>
  166629198054690816
 </id>
 <text>
  Post-Bowl Twitter analysis http://t.co/OYYSRSew http://t.co/M0AtLQVd
 </text>
 <source>
  web
 </source>
 <truncated>
  false
 </truncated>
 <favorited>
  false
 </favorited>
 <in_reply_to_status_id>
 </in_reply_to_status_id>
 <in_reply_to_user_id>
 </in_reply_to_user_id>
 <in_reply_to_screen_name>
 </in_reply_to_screen_name>
 <retweet_count>
  454
 </retweet_count>
 <retweeted>
  false
 </retweeted>
 <user>
  <id>
   783214
  </id>
  <name>
   Twitter
  </name>
  <screen_name>
   twitter
  </screen_name>
  <location>
   San Francisco, CA
  </location>
  <description>
   Always wondering what's happening.
  </description>
  <profile_image_url>
   http://a0.twimg.com/profile_images/1124040897/at-twitter_normal.png
  </profile_image_url>
  <profile_image_url_https>
   https://si0.twimg.com/profile_images/1124040897/at-twitter_normal.png
  </profile_image_url_https>
  <url>
   http://blog.twitter.com/
  </url>
  <protected>
   false
  </protected>
  <followers_count>
   7625563
  </followers_count>
  <profile_background_color>
   ACDED6
  </profile_background_color>
  <profile_text_color>
   333333
  </profile_text_color>
  <profile_link_color>
   038543
  </profile_link_color>
  <profile_sidebar_fill_color>
   F6F6F6
  </profile_sidebar_fill_color>
  <profile_sidebar_border_color>
   EEEEEE
  </profile_sidebar_border_color>
  <friends_count>
   822
  </friends_count>
  <created_at>
   Tue Feb 20 14:35:54 +0000 2007
  </created_at>
  <favourites_count>
   16
  </favourites_count>
  <utc_offset>
   -28800
  </utc_offset>
  <time_zone>
   Pacific Time (US &amp; Canada)
  </time_zone>
  <profile_background_image_url>
   http://a1.twimg.com/profile_background_images/378245879/Twitter_1544x2000.png
  </profile_background_image_url>
  <profile_background_image_url_https>
   https://si0.twimg.com/profile_background_images/378245879/Twitter_1544x2000.png
  </profile_background_image_url_https>
  <profile_background_tile>
   true
  </profile_background_tile>
  <profile_use_background_image>
   true
  </profile_use_background_image>
  <notifications>
   false
  </notifications>
  <geo_enabled>
   true
  </geo_enabled>
  <verified>
   true
  </verified>
  <following>
   true
  </following>
  <statuses_count>
   1266
  </statuses_count>
  <lang>
   en
  </lang>
  <contributors_enabled>
   true
  </contributors_enabled>
  <follow_request_sent>
   false
  </follow_request_sent>
  <listed_count>
   68708
  </listed_count>
  <show_all_inline_media>
   true
  </show_all_inline_media>
  <default_profile>
   false
  </default_profile>
  <default_profile_image>
   false
  </default_profile_image>
  <is_translator>
   false
  </is_translator>
 </user>
 <geo>
  <coordinates>
   <place>
    <possibly_sensitive>
     false
    </possibly_sensitive>
    <contributors>
     <user_id>
      7694352
     </user_id>
    </contributors>
   </place>
  </coordinates>
 </geo>
</status>

ネタ元: http://wozozo.hatenablog.com/entry/2012/02/08/121504

ちなみに-mだけでやる場合は細かい制御はできなさそう。
Posted at by | Edit