PowerShell : Bing Powered Auto-Complete
Prateek Singh
5x Author ?? | Staff SWE @LinkedIn ?? | Building with ReactJS ??, Python ?? & Gen AI ?? | LLMs & AI-Augmented Workflows ?? | Cloud & Observability Expert ????
Hello Readers,
In Today’s Blog post we’ll talk about the Bing API and how Bing Search Auto complete data can be fetched using PowerShell.
I was playing around with Web Debugger Tool (Fiddler) and while doing aBing search I noticed my Browser making HTTP request to Bing API URL.
Well API’s are always fun, so why not try and explore it with PowerShell ;)
HOW IT WORKS :
Before we proceed further time for some definitions :) so that all have same understanding –
API – Application Programming Interface is a set of functions and procedures that allow the creation of applications which access the features or data of an operating system, application, or other service.
REST – REST stands for Representational State Transfer. (It is sometimes spelled “ReST“.) It relies on a stateless, client-server, cacheable communications protocol and in virtually all cases, the HTTP protocol is used. REST is an architecture style for designing networked applications.
API’s which return Richly Structured data are called RESTFull API’s.
So, making it work is 3 step process :
- Make your Custom Query URL –
Like Fiddler Logs in the above screenshot, we’ll create a URL with a Custom Query string, something like below –URL : https://api.bing.com/qsml.aspx?query=Word
When you type this URL in a browser address bar and hit enter, you’ll see a structured data returned (XML Data).
- Send HTTP request to Bing API –
Using the PoweShell Invoke-RestMethod Cmdlet sending anHTTP request on URL mentioned in Step 1. - Data Mine the Structured Data returned –
Capture the useful information from the Structured data returned from the API and feed it to your GUI.
GET THE SCRIPT : Click here to go to my GitHub gist to get the code.
HOW TO USE IT :
Run the Script and type in your query in the TextBox. Form is intelligent enough to give you suggestions the moment you stop typing, like in the below animation
Hoping you find it fun.
Happy Reading :)