Ducky() for duckduckgo search engine

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Ducky() for duckduckgo search engine

09 Apr 2018, 09:17

Ducky() is a disappointingly limited alternate to Google's i'm feeling lucky.
Ducky() will attempt to return the URL of first result for a query and will silently fail and return blank when it succumbs to its limitations.

Usage example:

Code: Select all

MsgBox % Ducky( "autohotkey" )
MsgBox % Ducky( "autohotkey", "wikipedia.org" )
Function:

Code: Select all

Ducky( Query := "", Site := "" ) { ; SKAN | 09-Apr-2018 | goo.gl/SCySwW
Local Web, URL := "https://duckduckgo.com/html/?q=!ducky+" . Query . ( Site="" ? "" : "+site:" Site )
  Try 
  {
    Web := ComObjCreate( "WinHttp.WinHttpRequest.5.1" ),    Web.Open( "GET",URL,False ),   Web.Send()
    Return ( SubStr( Web.Option(1),1,27) <> "https://duckduckgo.com/html" ? Web.Option(1) : "" )
  }
}

My requirement:
I needed this to find Amazon Standard Identification Number (ASIN) of a product, which occurs at the end of an URL.
Example: MsgBox % Ducky( "Nikon+D7200", "amazon.in" )
Result: https://www.amazon.in/Nikon-D7200-24-2M ... B00W5FYN6U

Once I had the ASIN, I am able to use to view its price history for 1/3/12 months or all available data from keepa.com
https://keepa.com/#!product/10-B00W5FYN6U
Note: The "10" in above URL is amazon.in while "1" is amazon.com

:)
My Scripts and Functions: V1  V2
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Ducky() for duckduckgo search engine

09 Apr 2018, 11:21

That's great!

I just discovered that DuckDuckGo has an API that you could use for scraping data as well.

See here: https://api.duckduckgo.com/?q=!ducky+au ... redirect=1

The format parameter can be XML, JSON, etc.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: makdc96 and 141 guests