Welcome!

Blog Feed Post

Introducing PoshBing – The PowerShell library for Microsoft’s Bing Search Engine

PoshBing Microsoft released their new search engine called “Bing” at, aptly named, http://www.bing.com.  Microsoft is getting positive reviews from the likes of CNET, The Wall Street Journal, and TechCrunch.  Instead of posting my review of the site, I’ll let you browse the above links to find out what the services is all about.

What interested me about Bing is that Microsoft has released a full API to allow you to use their services in your applications.  The Bing API is documented at Microsoft’s developer site and I thought to myself how I could test it out.  The obvious answer was PowerShell of course.  My previous PoshTweet Twitter Library has been fairly popular so I figured I’d give a “library” type project another go around and tackle the Bing APIs.

The Bing API has the concept of “SourceTypes” which are essentially data sources that you can search into.  My script library provides access to the Image, InstantAnswer, News, MobileWeb, Phonebook, RelatedSearch, Spell, Web, Translation, and Video SourceTypes with the following functions:

  • Get-BingImage – Search the Image SourceType for a list of images including properties about the media files.
  • Get-BingInstantAnswer – Get single, authoritative answers to questions.
  • Get-BingNews – Provide news specific to a topic, a location, or breaking news.
  • Get-BingMobileWeb – Returns mobile web results, primarily relevant XHTML or WML pages.
  • Get-BingPhonebook – Enables you to view details about a business for which you are searching as if they were a phonebook entry.
  • Get-BingRelatedSearch – View searches that provide information in which you might be interested, based on your current search.
  • Get-BingSpell – Query alternative spellings for a given word or phrase.
  • Get-BingWeb – Get pages relevant to the queried terms.
  • Get-BingTranslation – Translate a term from one language to another.
  • Get-BingVideo – return a list of videos and their properties relevant to the query terms.

I’ve included parsing for the response streams for the above SourceTypes, but if you would like to get the raw XML back, all of the above functions include a “-raw” parameter to allow you to bypass the response processing.

Here’s the full function library, enjoy!

CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CR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CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
CRLF9
CRLF8
CRLF7
CRLF6
CRLF5
CRLF4
CRLF3
CRLF2
CRLF1
CRLF0
 799:   else
 800:   {
 801:     $options_hash = @{
 802:       "Translation.SourceLanguage" = $translation_sourcelanguage;
 803:       "Translation.TargetLanguage" = $translation_targetlanguage;
 804:     };
 805:     
 806:     $xml = Get-Bing -query $query -sources "Translation" `
 807:       -options_hash $options_hash -common_hash $common_hash;
 808:     if ( $raw )
 809:     {
 810:       $xml
 811:     }
 812:     else
 813:     {
 814:       Process-BingResponse $xml;
 815:     }
 816:   }
 817: }
 818:  
 819: #============================================================================
 820: # Video (2.1)
 821: #============================================================================
 822: function Get-BingVideo()
 823: {
 824:   param(
 825:     [string]$query = $null,
 826:     [int]$video_count = 2,
 827:     [int]$video_offset = 0,
 828:     [bool]$raw = $false
 829:   );
 830:   
 831:   $common_hash = Get-CommonFieldHash;
 832:   $common_hash["Version"] = "2.1";
 833:   
 834:   $options_hash = @{
 835:     "Video.Count" = $video_count;
 836:     "Video.Offset" = $video_offset;
 837:   };
 838:   
 839:   $xml = Get-Bing -query $query -sources "Video" `
 840:     -options_hash $options_hash -common_hash $common_hash;
 841:   if ( $raw )
 842:   {
 843:     $xml
 844:   }
 845:   else
 846:   {
 847:     Process-BingResponse $xml;
 848:   }
 849: }

You can download the full script from here: PoshBing.ps1

Read the original blog entry...

More Stories By Joe Pruitt

Joe Pruitt is a Principal Strategic Architect at F5 Networks working with Network and Software Architects to allow them to build network intelligence into their applications.

Latest Stories
What is the best strategy for selecting the right offshore company for your business? In his session at 21st Cloud Expo, Alan Winters, U.S. Head of Business Development at MobiDev, will discuss the things to look for - positive and negative - in evaluating your options. He will also discuss how to maximize productivity with your offshore developers. Before you start your search, clearly understand your business needs and how that impacts software choices.
Real IoT production deployments running at scale are collecting sensor data from hundreds / thousands / millions of devices. The goal is to take business-critical actions on the real-time data and find insights from stored datasets. In his session at @ThingsExpo, John Walicki, Watson IoT Developer Advocate at IBM Cloud, will provide a fast-paced developer journey that follows the IoT sensor data from generation, to edge gateway, to edge analytics, to encryption, to the IBM Bluemix cloud, to Wa...
Enterprises are moving to the cloud faster than most of us in security expected. CIOs are going from 0 to 100 in cloud adoption and leaving security teams in the dust. Once cloud is part of an enterprise stack, it’s unclear who has responsibility for the protection of applications, services, and data. When cloud breaches occur, whether active compromise or a publicly accessible database, the blame must fall on both service providers and users. In his session at 21st Cloud Expo, Ben Johnson, C...
Most of the time there is a lot of work involved to move to the cloud, and most of that isn't really related to AWS or Azure or Google Cloud. Before we talk about public cloud vendors and DevOps tools, there are usually several technical and non-technical challenges that are connected to it and that every company needs to solve to move to the cloud. In his session at 21st Cloud Expo, Stefano Bellasio, CEO and founder of Cloud Academy Inc., will discuss what the tools, disciplines, and cultural...
SYS-CON Events announced today that Fusic will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Fusic Co. provides mocks as virtual IoT devices. You can customize mocks, and get any amount of data at any time in your test. For more information, visit https://fusic.co.jp/english/.
SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
21st International Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Me...
SYS-CON Events announced today that Enroute Lab will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enroute Lab is an industrial design, research and development company of unmanned robotic vehicle system. For more information, please visit http://elab.co.jp/.
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
With the rise of DevOps, containers are at the brink of becoming a pervasive technology in Enterprise IT to accelerate application delivery for the business. When it comes to adopting containers in the enterprise, security is the highest adoption barrier. Is your organization ready to address the security risks with containers for your DevOps environment? In his session at @DevOpsSummit at 21st Cloud Expo, Chris Van Tuin, Chief Technologist, NA West at Red Hat, will discuss: The top security r...
IBM helps FinTechs and financial services companies build and monetize cognitive-enabled financial services apps quickly and at scale. Hosted on IBM Bluemix, IBM’s platform builds in customer insights, regulatory compliance analytics and security to help reduce development time and testing. In his session at 21st Cloud Expo, Lennart Frantzell, a Developer Advocate with IBM, will discuss how these tools simplify the time-consuming tasks of selection, mapping and data integration, allowing devel...
SYS-CON Events announced today that Mobile Create USA will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Mobile Create USA Inc. is an MVNO-based business model that uses portable communication devices and cellular-based infrastructure in the development, sales, operation and mobile communications systems incorporating GPS capabi...
Today traditional IT approaches leverage well-architected compute/networking domains to control what applications can access what data, and how. DevOps includes rapid application development/deployment leveraging concepts like containerization, third-party sourced applications and databases. Such applications need access to production data for its test and iteration cycles. Data Security? That sounds like a roadblock to DevOps vs. protecting the crown jewels to those in IT.
SYS-CON Events announced today that Interface Corporation will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Interface Corporation is a company developing, manufacturing and marketing high quality and wide variety of industrial computers and interface modules such as PCIs and PCI express. For more information, visit http://www.i...
SYS-CON Events announced today that Keisoku Research Consultant Co. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Keisoku Research Consultant, Co. offers research and consulting in a wide range of civil engineering-related fields from information construction to preservation of cultural properties. For more information, vi...