0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

paiza.ioでpython その5

Posted at

概要

paiza.ioでpythonやってみた。
練習問題やってみた。

練習問題

qiitaapiを叩け。

サンプルコード

# coding: utf-8

import requests
import json

page = 1
per_page = 5

print("作成日,タイトル,URL,いいねカウント")
url = 'https://qiita.com/api/v2/users/ohisama@github/items'
headers = {
    "content-type" : "application/json", 
    #"Authorization" : "Bearer xxxxxxxxxxxxxx" 
}
params = { 
    "page": str(page), 
    "per_page": str(per_page)
}
res = requests.get(url, headers=headers, params=params)
list = res.json()
#print(list)
for item in list:
    item_id = item['id']
    title = item['title']
    likes_cnt = item['likes_count']
    create_date = item['created_at']
    item_url = item['url']
    print(create_date + ", " + title + ", " + item_url + ", " + str(likes_cnt))




実行結果

作成日,タイトル,URL,いいねカウント
2023-04-04T21:19:51+09:00, paiza.ioでpython その4, https://qiita.com/ohisama@github/items/a589a615d2012636ea3c, 0
2023-04-04T15:53:15+09:00, paiza.ioでpython その3, https://qiita.com/ohisama@github/items/25e36c06979be784a327, 0
2023-04-04T15:39:57+09:00, paiza.ioでpython その2, https://qiita.com/ohisama@github/items/2bda3bab5a049e72fff9, 0
2023-04-04T05:58:35+09:00, cscの作法 その300, https://qiita.com/ohisama@github/items/aebdd9b6dc2be2d92901, 0
2023-04-03T08:10:21+09:00, cscの作法 その299, https://qiita.com/ohisama@github/items/0c53d06d5745804d866b, 0

成果物

以上。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?