
Web
|
325
例
18-1
ia.py
import json
import sys
import requests
def search(title):
url = "https://exl.ptpress.cn:8442/ex/l/b5cb0306"
params = {"q": f"title:({title})",
"output": "json",
"fields": "identifier,title",
"rows": 50,
"page": 1,}
resp = requests.get(url, params=params)
return resp.json()
if __name__ == "__main__":
title = sys.argv[1]
data = search(title)
docs = data["response"]["docs"]
print(f"Found {len(docs)} items, showing first 10")
print("identifier\ttitle")
for row in docs[:10]:
print(row["identifier"], row["title"], sep="\t")
wendigo
都有哪些?
$
python ia.py wendigo
Found 24 items, showing first 10
identifier title
cd_wendigo_penny-sparrow ...