In [1]:
import requests

In [2]:
url = 'https://note.nkmk.me'

In [3]:
hb_count = 'http://api.b.st-hatena.com/entry.count'

In [4]:
r = requests.get(hb_count, params={'url': url})

In [5]:
print(r.url)


http://api.b.st-hatena.com/entry.count?url=https%3A%2F%2Fnote.nkmk.me

In [6]:
print(r.text)


5

In [7]:
print(type(r.text))


<class 'str'>

In [8]:
print(int(r.text))


5

In [9]:
print(type(int(r.text)))


<class 'int'>

In [10]:
hb_counts = 'http://api.b.st-hatena.com/entry.counts'

In [11]:
r = requests.get(hb_counts, params={'url': ['https://www.google.co.jp', 'https://www.yahoo.co.jp']})

In [12]:
print(r.url)


http://api.b.st-hatena.com/entry.counts?url=https%3A%2F%2Fwww.google.co.jp&url=https%3A%2F%2Fwww.yahoo.co.jp

In [13]:
j = r.json()

In [14]:
print(j)


{'https://www.google.co.jp': 1385, 'https://www.yahoo.co.jp': 313}

In [15]:
print(type(j))


<class 'dict'>

In [16]:
hb_total_count = 'http://api.b.st-hatena.com/entry.total_count'

In [17]:
r = requests.get(hb_total_count, params={'url': url})

In [18]:
print(r.url)


http://api.b.st-hatena.com/entry.total_count?url=https%3A%2F%2Fnote.nkmk.me

In [19]:
j = r.json()

In [20]:
print(j)


{'url': 'https://note.nkmk.me', 'total_bookmarks': 324}

In [21]:
print(j['total_bookmarks'])


324

In [22]:
hb_entry = 'http://b.hatena.ne.jp/entry/jsonlite/'

In [23]:
r = requests.get(hb_entry, params={'url': url})

In [24]:
print(r.url)


http://b.hatena.ne.jp/entry/jsonlite/?url=https%3A%2F%2Fnote.nkmk.me

In [25]:
j = r.json()

In [26]:
import pprint

pprint.pprint(j)


{'bookmarks': [{'comment': '',
                'tags': ['*Python'],
                'timestamp': '2018/06/02 10:52',
                'user': 'pkdick'},
               {'comment': '',
                'tags': [],
                'timestamp': '2018/05/22 16:24',
                'user': 'ilford400'},
               {'comment': '',
                'tags': ['python'],
                'timestamp': '2018/05/02 14:12',
                'user': 'yem3399op'}],
 'count': 5,
 'eid': '356280517',
 'entry_url': 'http://b.hatena.ne.jp/entry/s/note.nkmk.me/',
 'screenshot': 'http://b.hatena.ne.jp/images/v4/public/common/noimage.png',
 'title': 'nkmk note',
 'url': 'https://note.nkmk.me/'}

In [27]:
print(type(j['bookmarks']))


<class 'list'>

In [28]:
print(type(j['bookmarks'][0]))


<class 'dict'>

In [29]:
for b in j['bookmarks']:
    print(b['timestamp'])


2018/06/02 10:52
2018/05/22 16:24
2018/05/02 14:12