/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
- // Steve Phillips / elimisteve
- // 2012.12.18
- package main
- import (
- "fmt"
- "github.com/elimisteve/ddg"
- "log"
- )
- const (
- DDG_API_BASE_URL = "api.duckduckgo.com"
- DDG_API_URL = "http://api.duckduckgo.com/?q=%s&format=json"
- DDG_API_URL_SECURE = "https://api.duckduckgo.com/?q=%s&format=json"
- DEBUG = true
- )
- func main() {
- query := "define wikipedia"
- resp, err := ddg.Query(query)
- if err != nil {
- log.Printf("Error calling ddg.Query: %v\n", err)
- return
- }
- fmt.Printf("%s: %s\n", query, resp.Abstract)
- }