A | B |
---|
9781234567890 | =fetchData(A1) |
ってやれば取れると思う。ちょっと関数がまともに動かなくなったんで途中から検証できてないですが。
javascript
1function fetchData(isbn) {
2 const elm = parseXml(reqInfo(isbn));
3 const NsDc = XmlService.getNamespace("dc", 'http://purl.org/dc/elements/1.1/');
4 const NsDcNdl = XmlService.getNamespace("dcndl", 'http://ndl.go.jp/dcndl/terms/');
5 return [getTitle(elm, NsDc) || "", getSeriesTitle(elm, NsDcNdl) || "", getCreator(elm, NsDc) || "", getPublisher(elm, NsDc) || "", getPubDate(elm) || "", getExtent(elm, NsDc) || "", getVolume(elm, NsDcNdl) || "", getEdition(elm, NsDcNdl) || "",];
6}
7function buildUrl(isbn) {
8 return 'http://iss.ndl.go.jp/api/opensearch?isbn=' + isbn
9}
10function reqInfo(isbn) {
11 return UrlFetchApp.fetch(buildUrl(isbn)).getContentText();
12}
13function parseXml(xmlString) {
14 return XmlService.parse(xmlString).getRootElement().getChildren("channel")[0].getChildren("item")[0];
15}
16function getTitle(itemElement, ns) {
17 return getChildTextOfNs(itemElement, ns,"title");
18}
19function getSeriesTitle(itemElement, ns) {
20 return getChildTextOfNs(itemElement, ns, "seriesTitle");
21}
22function getCreator(itemElement, ns) {
23 return getChildTextOfNs(itemElement, ns,"creator");
24}
25function getPublisher(itemElement, ns) {
26 return getChildTextOfNs(itemElement, ns,"publisher");
27}
28function getPubDate(itemElement) {
29 return getChildTextOf(itemElement, "pubDate");
30}
31function getExtent(itemElement, ns) {
32 return getChildTextOfNs(itemElement, ns, "extent");
33}
34function getVolume(itemElement, ns) {
35 return getChildTextOfNs(itemElement, ns,"volume");
36}
37function getEdition(itemElement, ns) {
38 return getChildTextOfNs(itemElement, ns,"edition");
39}
40function getChildTextOf(elem, name) {
41 return elem ? elem.getChildText(name) : "";
42}
43function getChildTextOfNs(elem, ns, name) {
44 return elem ? elem.getChildText(name, ns) : "";
45}