fumika

package module
v0.0.0-...-def5061 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2017 License: MIT Imports: 9 Imported by: 0

README

fumika

중고책 매입가 검색 API

Build Status

Features

Test

# (optional) download testdata 
cd testdata
python fetch.py

go test

Usage

Aladin

examples/aladin/main.go

package main

import (
	"fmt"
	"net/http"

	"github.com/if1live/fumika"
)

func main() {
	client := http.Client{}
	api := fumika.NewAladin(&client)
	isbn := "9788926790403"
	result, err := api.SearchISBN(isbn)
	if err != nil {
		panic(err)
	}

	fmt.Println("title: ", result.Title)
	fmt.Println("unit price: ", result.UnitPrice)
	fmt.Println("price best: ", result.PriceBest)
	fmt.Println("price good: ", result.PriceGood)
	fmt.Println("price normal: ", result.PriceNormal)
}
title:  기어와라! 냐루코 양 1
unit price:  6000
price best:  600
price good:  500
price normal:  400
Yes24

examples/yes24/main.go

package main

import (
	"fmt"
	"net/http"

	"github.com/if1live/fumika"
)

func main() {
	client := http.Client{}
	api := fumika.NewYes24(&client)
	isbn := "9788926790403"
	result, err := api.SearchISBN(isbn)
	if err != nil {
		panic(err)
	}

	fmt.Println("title: ", result.Title)
	fmt.Println("unit price: ", result.UnitPrice)
	fmt.Println("price best: ", result.PriceBest)
	fmt.Println("price good: ", result.PriceGood)
	fmt.Println("price normal: ", result.PriceNormal)
}
title:  기어와라! 냐루코 양 1
unit price:  6000
price best:  600
price good:  600
price normal:  500

Development Note

Build README
go get github.com/if1live/maya
maya -file=document/README.mkdn -mode=pelican > README.md

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetElementByClassName

func GetElementByClassName(n *html.Node, classname string) *html.Node

func GetElementByID

func GetElementByID(n *html.Node, id string) *html.Node

func GetElementsByClassName

func GetElementsByClassName(n *html.Node, classname string) []*html.Node

func GetElementsByTagName

func GetElementsByTagName(n *html.Node, tag string) []*html.Node

func SanitizeISBN

func SanitizeISBN(code string) (string, bool)

Types

type AladinAPI

type AladinAPI struct {
	// contains filtered or unexported fields
}

func NewAladin

func NewAladin(client *http.Client) *AladinAPI

func (*AladinAPI) SearchISBN

func (api *AladinAPI) SearchISBN(isbn string) (SearchResult, error)

type SearchAPI

type SearchAPI interface {
	SearchISBN(isbn string) (SearchResult, error)
}

type SearchResult

type SearchResult struct {
	// metadata
	SearchedISBN string `json:"searched_isbn"`
	Title        string `json:"title"`

	UnitPrice   int `json:"unit_price"`
	PriceBest   int `json:"price_best"`
	PriceGood   int `json:"price_good"`
	PriceNormal int `json:"price_normal"`
}

type Yes24API

type Yes24API struct {
	// contains filtered or unexported fields
}

func NewYes24

func NewYes24(client *http.Client) *Yes24API

func (*Yes24API) SearchISBN

func (api *Yes24API) SearchISBN(isbn string) (SearchResult, error)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL