Skip to content

Instantly share code, notes, and snippets.

@kurozumi kurozumi/hatebu.xmlrpc.py

Last active Feb 29, 2016
Embed
What would you like to do?
【Python】標準入力したURLのはてなブックマークの合計数を標準出力する方法
# coding: utf-8
import urllib
import xmlrpclib
while True:
# 標準入力の値を取得
uri = raw_input()
# urlをパース
type, uri = urllib.splittype(uri)
# urlのスキームをチェック
if type not in ("http", "https"):
raise IOError("unsupported protocol")
server = xmlrpclib.ServerProxy("http://b.hatena.ne.jp/xmlrpc")
# はてブの合計数を出力
print server.bookmark.getTotalCount(type + ":" + uri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.