Help us understand the problem. What is going on with this article?

Pythonで国立国会図書館サーチAPIを使用

More than 3 years have passed since last update.

使用するAPI

国立国会図書館サーチ外部提供インタフェース(API)

使用するライブラリ

https://github.com/nocotan/pyndlsearch

test.py
# -*- coding: utf-8 -*-

from pyndlsearch.client import SRUClient
from pyndlsearch.cql import CQL


if __name__ == '__main__':
    # CQL検索クエリの組み立て
    cql = CQL()
    cql.title = 'Python'
    cql.fromdate = '2000-10-10'
    #print(cql.payload())

    # NDL Searchクライアントの設定
    client = SRUClient(cql)
    client.set_maximum_records(2)
    #print(client)

    # get_response()ではxml形式で取得可能
    #res = client.get_response()
    #print(res.text)

    # SRU
    srres = client.get_srresponse()

    for record in srres.records:
        print(record.recordData.title)
        print(record.recordData.creator)
  • 出力結果
10日でおぼえるPython入門教室
穂苅実紀夫, 寺田学, 中西直樹, 堀田直孝, 永井孝 著
1500円定番ARMマイコン・ボードで試して合点! アプリはスクリプトで柔軟に!マイコン用MicroPythonプログラミング
中村 晋一郎

説明

API仕様書に記載されているCQLという検索クエリを組み立てて検索します.

Responseは構造化されたものを得るget_srresponse()か生のxmlを得るget_response()を使用できます.

searchRetrieveResponse

  • version
  • numberOfRecords
  • nextRecordPosition
  • extraResponseData
    • facets {
      REPOSITORY_NO,
      NDC,
      ISSUED_DATE,
      LIBRARY,
      }
  • records
    • recordSchema
    • recordPacking
    • recordData{
      title,
      creator,
      descriptions,
      publisher,
      language,
      }
    • recordPosition

pyndlsearch

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした