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)
In [6]:
print(r.text)
In [7]:
print(type(r.text))
In [8]:
print(int(r.text))
In [9]:
print(type(int(r.text)))
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)
In [13]:
j = r.json()
In [14]:
print(j)
In [15]:
print(type(j))
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)
In [19]:
j = r.json()
In [20]:
print(j)
In [21]:
print(j['total_bookmarks'])
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)
In [25]:
j = r.json()
In [26]:
import pprint
pprint.pprint(j)
In [27]:
print(type(j['bookmarks']))
In [28]:
print(type(j['bookmarks'][0]))
In [29]:
for b in j['bookmarks']:
print(b['timestamp'])