andrewrjones/ruby-duck-duck-go — pull request #5 by Qeole (2014-08-01 00:36:40+00:00)
Title: Support for redirect links (through !bang syntax)

Hi Andrew,

I suppose you saw my previous pull request (I can't be sure, this is the first time I'm using GitHib, actually).
This time I fixed the issue that made me close the PR.

So I had an issue with the DuckDuckGo `!bang` syntax, which usually redirects to other websites (e.g. https://ddg.gg/?q=!w+duckduckgo redirects to DuckDuckGo on Wikipedia):
`ddg.zeroclickinfo("!w duckduckgo")` would return source HTML from Wikipedia instead of a redirection link from DuckDuckGo.

I fixed it by adding a `no_redirect=1` HTTP argument to the request, based on following API example from the API page: https://api.duckduckgo.com/?q=!imdb+rushmore&format=json&pretty=1&no_redirect=1. `no_redirect=1` is added whether or not !bang syntax is used, but it does not seem to modify anything for other (non-redirected) results.

I also added a `redirect` member to `zeroclickinfo` so as to get this link from DuckDuckGo's answer.