PageRenderTime 101ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/README.md

http://github.com/ajanicij/goduckgo
Markdown | 104 lines | 75 code | 29 blank | 0 comment | 0 complexity | 02012f6675cdd42a3d57fcef5f8c2843 MD5 | raw file
  1. goduckgo [![Build Status](https://travis-ci.org/ajanicij/goduckgo.svg?branch=master)](https://travis-ci.org/ajanicij/goduckgo)[![GoDoc](https://godoc.org/github.com/ajanicij/goduckgo/goduckgo?status.png)](http://godoc.org/github.com/ajanicij/goduckgo/goduckgo)
  2. ========
  3. Go package for DuckDuckGo Instant Answer API.
  4. [DuckDuckGo](http://duckduckgo.com) is a search engine that:
  5. * Emphasizes privacy
  6. * Does not record user information
  7. * Breaks out of the filter bubble
  8. The Instant Answer API is described [here](http://duckduckgo.com/api.html). For
  9. example, the URL for querying about New York City is
  10. [http://api.duckduckgo.com/?q=New+York+City&format=json&pretty=1](http://api.duckduckgo.com/?q=New+York+City&format=json&pretty=1)
  11. The previous query causes DuckDuckGo to return the result in JSON format.
  12. Function goduckgo.Query declared as
  13. ```
  14. func Query(query string) (*Message, error)
  15. ```
  16. generates the URL, sends it to DuckDuckGo, receives the result, unmarshals from
  17. JSON format to Message structure and returns a pointer to the structure.
  18. Installation
  19. ------------
  20. ```
  21. go get -u github.com/ajanicij/goduckgo
  22. ```
  23. Usage
  24. -----
  25. Look at the source for the command-line utility, `main.go`. It imports
  26. package `github.com/ajanicij/goduckgo/goduckgo`, generates the query in the variable
  27. `query` (for example, "New York City") and passes it to function
  28. `goduckgo.Query`. That function returns two values: `*Message` and `error`.
  29. Command-line utility
  30. --------------------
  31. The source code of the command-line utility is `main.go`. It builds `goduckgo`
  32. command. Its usage is:
  33. `goduckgo [{flags}] <query>`
  34. Flags determine which fields we will see in the result.
  35. For example, if we want to search for "New York City," we can issue command
  36. `goduckgo -All New York City`
  37. Flag -All tells the command that we want all fields.
  38. Command
  39. `goduckgo -help`
  40. (or `goduckgo` without any flags) will give us a help string that lists
  41. all available options:
  42. ```
  43. Usage of ./goduckgo:
  44. -Abstract=false: Abstract
  45. -AbstractSource=false: Abstract Source
  46. -AbstractText=false: Abstract Text
  47. -AbstractURL=false: Abstract URL
  48. -All=false: All Fields
  49. -Answer=false: Answer
  50. -AnswerType=false: Answer Type
  51. -Definition=false: Definition
  52. -DefinitionSource=false: Definition Source
  53. -DefinitionURL=false: Definition URL
  54. -Heading=false: Heading
  55. -Image=false: Image
  56. -Redirect=false: Redirect
  57. -RelatedTopics=false: Related Topics
  58. -Results=false: Results
  59. -Type=false: Type
  60. ```
  61. For example, query
  62. `goduckgo -Abstract DuckDuckgo`
  63. produces the following:
  64. ```
  65. Abstract: DuckDuckGo is an Internet search engine that emphasizes protecting searchers'
  66. privacy and avoiding the "filter bubble" of personalized search results. DuckDuckGo
  67. distinguishes itself from other search engines by not profiling its users and by deliberately
  68. showing all users the same search results for a given search term. DuckDuckGo also
  69. emphasizes getting information from the best sources rather than the most sources,
  70. generating its search results from key crowdsourced sites such as Wikipedia and from
  71. partnerships with other search engines like Yandex, Yahoo!, Bing, Wolfram Alpha and Yummly.
  72. ```
  73. License
  74. -------
  75. `goduckgo` is MIT licensed, see [here](https://github.com/ajanicij/goduckgo/blob/master/LICENSE).