1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Qiita APIを使って直近100件のタイトルだけ取得する

Last updated at Posted at 2021-08-27

技術トレンドを word Cloud で見せたいな、と思った時の技術トレンドの拾い上げ(メモ)

参考記事

結論

# python --version
Python 2.7.5
# _*_ coding: utf-8 _*_

import requests
import urllib
import json
import sys
import codecs
from bs4 import BeautifulSoup

# webAPIからJSON形式の文字列の結果を取得し返却する
def getData():

    # proxy設定
    proxies = {
        "http":"プロキシサーバ:ポート",
        "https":"プロキシサーバ:ポート"
    }

    # API
    url = 'http://qiita.com/api/v2/items?'

    # APIパラメータセット
    param = {
        'page': '1',        # ページ番号(1-100)
        'per_page' : '100'  # 1ページ要素数(1-100)
    }

    # パラメータ文字列作成
    paramStr = urllib.urlencode(param)

    # APIを叩いて変数に結果を格納
    response = requests.get(url + paramStr, proxies=proxies)

    # JSONに変換
    jsonData = response.json()

    # 配列の中にJSONが入っているので配列要素毎にループ
    for jsonObj in jsonData:
        # 欲しいのはタイトルだけ
        print(jsonObj["title"])

    return response

# main
if __name__ == '__main__':

    # webAPIからJSON形式の文字列の結果を取得する
    apiRes = getData()

結果

Wordpressで固定ページのURLを変えるには
ASP.NET MVC CSV出力メモ
[Ruby on rails]ゲストログイン機能 ゲストログインは削除、編集されないようにする
GCP Data engineer 合格体験記
Dataiku:社名の由来とその読み方
[JS]簡単なフォームバリデーション
無心でコピペしてGitOpsを試してみた with Argo CD
EC2に自動でEIPを割り当ててくれるシェルスクリプト
[Mac]Windowのどこをドラッグしても移動できるアプリの実装について
OpenSSL で複数のホスト名に対応した自己署名証明書を作成するには
IBM Cloud internet services (CIS)からROKSのpodにアクセスしてみた
Nest-js Headerデコレータのカスタム
JSON
[axios] ファイルダウンロードができない or 空ファイルになってしまう現象の解消
PowerAutomateDesktopのexcelまとめ記事はpowerhacksさんの所が良い予感……
flutter_flavorizr + flutter_flavorでFlutterの環境切り替えした後に、iOSでbuildした時の 「Unable to load contents of file list」の解決方法
Node.js(axios)からDirectCloud-BOX APIでファイル一覧の取得とnode話
【GCP】利用料割引しているパートナーを調査
OKtaの検証用アカウントを取得してみる
Vue.js開発中のエラー対処
【Ruby on rails】JavaScript 非同期通信のコメント機能でエラーメッセージを出す バリデーション
AWSのEC2インスタンスでAmazon Correttoを用いてJDK16を導入する
Terraform+SAMでLambda+APIGatewayの環境構築
CodeceptJSのhelper、playWright vs WebDriver
QNAPにgitea入れるメモ
:
:
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?