惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
小众软件
小众软件
美团技术团队
Martin Fowler
Martin Fowler
爱范儿
爱范儿
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
J
Java Code Geeks
B
Blog
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
博客园 - Franky

林中阴影

林中阴影 | 关于蓝光刻录的一些调查 林中阴影 | 与IPv6地址战斗 林中阴影 | 半年前的NAS升级 林中阴影 | “智能” 家居笔记:一→两年后的回顾 林中阴影 | 旧手机做RDP客户端的一些尝试 林中阴影 | 一些矿渣的耗电量 林中阴影 | 穷人的IP-KVM远程访问 林中阴影 | 内网访问第三季:在运营商的CGNAT网络下 林中阴影 | “智能”家居笔记,其之二 林中阴影 | “智能”家居笔记,其之一 林中阴影 | 仅IPv6家庭内网服务实现v6+v4双栈访问 林中阴影 | 下载装小蜜监理拍摄的图片 林中阴影 | 几物互联 林中阴影 | 整了个“新”平板 林中阴影 | 获取招商信用卡账单的另一种方法 林中阴影 | 我在GitHub的⭐ 林中阴影 | Python与光学计算,2021 林中阴影 | 你可能并不需要内网穿透 林中阴影 | 2020 林中阴影 | 和(基本上)什么也不能连的电脑传递信息 林中阴影 | 我将贻笑于大方之家 林中阴影 | 一个新主题 林中阴影 | 2019过去了,我…… 林中阴影 | Beancount试用,半年后 林中阴影 | 自动输入剪贴板中的内容 林中阴影 | Unicode与数学公式 林中阴影 | Python中光学计算相关的库/Awesome Python for Optics 林中阴影 | 一本厕纸小说 林中阴影 | 震惊!为了在Windows上访问EXT4分区,他竟然做出了这样的事! 林中阴影 | 我的2018
林中阴影 | 这次是纽约公共图书馆……的第二天!
2018-02-22 · via 林中阴影

(精神上)坐在图书馆里,我想:能不能把这些旧书借走呢?

当然是可以的!贴心的图书管理员已经提供了API接口:http://api.repo.nypl.org/,申请账号之后,就可以做各种各样的事了~

当然,如果只是想下片的话,用digital-collections可能会更简单一些:

digital-collections -t API_TOKEN -s UUID -o OUTPUT.json

其中,API_TOKEN在申请账号以后会得到一个;在你想要下载的专辑(比如这个)下面,可以看到UUID;运行这条命令之后,图片的信息列表会保存在OUTPUT.json里。

对,就是那个Universal Unique Identifier

之后,获得的json文件大概像是这样:

{
	"uuid": "510d47dd-c1f5-a3d9-e040-e00a18064a99",
	"imageLinks": {
		"imageLink": [
			"http://images.nypl.org/index.php?id=1125721&t=w&download=1&suffix=510d47dd-c1f5-a3d9-e040-e00a18064a99.001",
			"http://images.nypl.org/index.php?id=1125721&t=r&download=1&suffix=510d47dd-c1f5-a3d9-e040-e00a18064a99.001",
			"http://images.nypl.org/index.php?id=1125721&t=t&download=1&suffix=510d47dd-c1f5-a3d9-e040-e00a18064a99.001",
			"http://images.nypl.org/index.php?id=1125721&t=b&download=1&suffix=510d47dd-c1f5-a3d9-e040-e00a18064a99.001",
			"http://images.nypl.org/index.php?id=1125721&t=f&download=1&suffix=510d47dd-c1f5-a3d9-e040-e00a18064a99.001"
		]
	},
	"apiUri": "http://api.repo.nypl.org/api/v1/items/mods/510d47dd-c1f5-a3d9-e040-e00a18064a99",
	"typeOfResource": "still image",
	"imageID": "1125721",
	"sortString": "0000000001|0000000002|0000000001",
	"itemLink": "http://digitalcollections.nypl.org/items/510d47dd-c1f5-a3d9-e040-e00a18064a99",
	"highResLink": "http://link.nypl.org/7nC9VyT_TJWvGX9_H0mYBQ8",
	"title": "Dandelion.",
	"dateDigitized": "2016-08-04T04:53:12Z",
	"rightsStatement": "The New York Public Library believes that this item is in the public domain under the laws of the United States, but did not make a determination as to its copyright status under the copyright laws of other countries. This item may not be in the public domain under the laws of other countries. Though not required, if you want to credit us as the source, please use the following statement, \"From The New York Public Library,\" and provide a link back to the item on our Digital Collections site. Doing so helps us track how our collection is used and helps justify freely releasing even more content in the future.",
	"rightsStatementURI": "http://rightsstatements.org/vocab/NoC-US/1.0/"
}

之后,只要下载imageLink就好了。我用了一个简单的python脚本来做这件事。

# 注意:这玩意没有经过测试,可能会爆炸
# 啊对了,而且是python3.6
import urllib.request as ur
import json
import os

dir_name="Himalayan_plants" #可能要改这里……
os.mkdir(dir_name)
with open("OUTPUT.json","r") as source: #……还有这里
    source_dict=json.load(source)

for _i,_s in enumerate(source_dict):
    file_name=dir_name+"/"+str(_i)+".jpg"
    if os.path.exists(file_name)==False:
        try:
            ur.urlretrieve(_s["imageLinks"]["imageLink"][0],file_name)
        except Exception as e:
            print(_i)
            print(str(e))