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" )
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