Created
November 24, 2021 01:41
-
-
Save aidiary/a70c1b8bd46208e1d3b61e90079d3dbc to your computer and use it in GitHub Desktop.
ISBNから書籍タイトルを取得する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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