Skip to content

Instantly share code, notes, and snippets.

@aidiary
Created November 24, 2021 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aidiary/a70c1b8bd46208e1d3b61e90079d3dbc to your computer and use it in GitHub Desktop.
Save aidiary/a70c1b8bd46208e1d3b61e90079d3dbc to your computer and use it in GitHub Desktop.
ISBNから書籍タイトルを取得する
import json
import requests
url = 'https://www.googleapis.com/books/v1/volumes?q=isbn:'
with open('list.txt', 'r') as f:
for line in f.readlines():
isbn = line.rstrip()
res = requests.get(url + isbn, headers={"content-type": "application/json"}).json()
title = res['items'][0]['volumeInfo']['title']
print(f'{isbn},{title}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment