PageRenderTime 39ms CodeModel.GetById 37ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/go1/duckduckgo-parse.go

https://github.com/sbhackerspace/sbhx-snippets
Go | 27 lines | 21 code | 4 blank | 2 comment | 2 complexity | f8916bbf8e1627a816be67d2cc5c0a0d MD5 | raw file
 1// Steve Phillips / elimisteve
 2// 2012.12.18
 3
 4package main
 5
 6import (
 7	"fmt"
 8	"github.com/elimisteve/ddg"
 9	"log"
10)
11
12const (
13	DDG_API_BASE_URL   = "api.duckduckgo.com"
14	DDG_API_URL        = "http://api.duckduckgo.com/?q=%s&format=json"
15	DDG_API_URL_SECURE = "https://api.duckduckgo.com/?q=%s&format=json"
16	DEBUG = true
17)
18
19func main() {
20	query := "define wikipedia"
21	resp, err := ddg.Query(query)
22	if err != nil {
23		log.Printf("Error calling ddg.Query: %v\n", err)
24		return
25	}
26	fmt.Printf("%s: %s\n", query, resp.Abstract)
27}