PageRenderTime 176ms CodeModel.GetById 40ms 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. package main
  4. import (
  5. "fmt"
  6. "github.com/elimisteve/ddg"
  7. "log"
  8. )
  9. const (
  10. DDG_API_BASE_URL = "api.duckduckgo.com"
  11. DDG_API_URL = "http://api.duckduckgo.com/?q=%s&format=json"
  12. DDG_API_URL_SECURE = "https://api.duckduckgo.com/?q=%s&format=json"
  13. DEBUG = true
  14. )
  15. func main() {
  16. query := "define wikipedia"
  17. resp, err := ddg.Query(query)
  18. if err != nil {
  19. log.Printf("Error calling ddg.Query: %v\n", err)
  20. return
  21. }
  22. fmt.Printf("%s: %s\n", query, resp.Abstract)
  23. }