https://github.com/zuki/cinii
ci.nii.ac.jpにアクセスするgoライブラリ
https://github.com/zuki/cinii
Last synced: 8 months ago
JSON representation
ci.nii.ac.jpにアクセスするgoライブラリ
- Host: GitHub
- URL: https://github.com/zuki/cinii
- Owner: zuki
- Created: 2016-05-24T09:23:29.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-28T10:02:08.000Z (almost 10 years ago)
- Last Synced: 2024-12-27T13:10:23.189Z (over 1 year ago)
- Language: Go
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# github/zuki/cinii
CiNii Books APIを実装したパッケージ
## インストール
```sh
go get github/zuki/cinii
```
## 利用方法
- NCIDを指定してタイトルとタイトルの読みを出力
```golang
package main
import (
"fmt"
"github.com/zuki/cinii"
)
func main() {
record, err := cinii.Get("BB19132110", "Your CiNii appid")
if err == nil {
title := record.Title()
fmt.Printf("%s (%s)\n", title[0], title[1])
}
}
```
- OpenSearchを"Go言語"で検索してタイトルと著者を表示
```golang
package main
import (
"fmt"
"net/url"
"github.com/zuki/cinii"
)
func main() {
appid := "Your CiNii appid"
q := url.Values{}
q.Set("q", "Go言語")
q.Set("appid", appid)
feed, err := cinii.Search(q)
if err != nil {
log.Fatal(err)
}
for _, entry := range feed.Entries {
record, err := cinii.Get(entry.ID, appid)
if err != nil {
log.Fatal(err)
}
fmt.Printf("タイトル: %s\n", record.Title()[0])
if authors, ok := record.Authors(); ok {
for i, author := range authors {
if i == 0 {
fmt.Print("著者: ")
} else {
fmt.Print("; ")
}
fmt.Print(author[0])
}
fmt.Println("")
}
fmt.Println("")
}
}
```
## 著作権
MIT