Welcome!

A Software Architect Living in a Networking World

Joe Pruitt

Subscribe to Joe Pruitt: eMailAlertsEmail Alerts
Get Joe Pruitt via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Related Topics: Intel XML, Twitter on Ulitzer, XML Magazine, Air Travel Journal, New Media on Ulitzer

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
CRLF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LF5
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
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.