diff --git a/README.md b/README.md index ef2fb8a..77b99ad 100644 --- a/README.md +++ b/README.md @@ -36,21 +36,21 @@ $ goscholar -h ```go // create Query and generate URL -q := Query{Keywords:"deep learning", Author:"y bengio"} -url = q.SearchUrl() +q := Query{Keywords:"nature 2015", Author:"y bengio", Title:"Deep learning"} +url := q.SearchUrl() // fetch document sending the request to the URL -doc, err := goscholar.Fetch(url) +doc, err := Fetch(url) if err != nil { - log.Error(err) + log.Error(err) return } // parse articles -ch := make(chan *goscholar.Article, 10) -go goscholar.ParseDocument(ch, doc) - +ch := make(chan *Article, 10) +go ParseDocument(ch, doc) for a := range ch { + fmt.Println("---") fmt.Println(a) } ``` diff --git a/parse_test.go b/parse_test.go index 4a53906..fb4e991 100644 --- a/parse_test.go +++ b/parse_test.go @@ -75,38 +75,24 @@ func checkWithFirst(doc *goquery.Document, aExpected *Article) (err error) { } func Example() { - ch := make(chan *Article, 10) - + // create Query and generate URL q := Query{Keywords:"nature 2015", Author:"y bengio", Title:"Deep learning"} url := q.SearchUrl() + // fetch document sending the request to the URL doc, err := Fetch(url) if err != nil { log.Error(err) return } + // parse articles + ch := make(chan *Article, 10) go ParseDocument(ch, doc) - a := <- ch - fmt.Println(a) - // Output: - /*[Title] - Name: Deep learning - Url: http://www.nature.com/nature/journal/v521/n7553/abs/nature14539.html -[Year] - 2015 -[ClusterId] - 5362332738201102290 -[NumCite] - 390 -[NumVer] - 7 -[InfoId] - 0qfs6zbVakoJ -[Link] - Name: psu.edu - Url: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.436.894&rep=rep1&type=pdf - Format: PDF*/ + for a := range ch { + fmt.Println("---") + fmt.Println(a) + } } func TestParseSelection(t *testing.T) {