lakshman
Comments
Reactions

Python Wrapper on Bing API

By : lakshman

The newly launched search engine Bing has a simple restful API. We have created a thin Python wrapper over this API, which allows to query the Bing servers in a very pythonic way.

Installing this is as easy as easy_install bingapi.

[Or get it here or here ]

Using

from bingapi import bingapi
bing = bingapi.Bing(<appid>)
bing.do_web_search('Usware Technologies')

The README from the project is posted below, which provides more details on using this.

bingapi.py is a very thin python wrapper over the Bing API. Bing provides a very simple Restful interface to their search engine and provides results in JSON and XML interface.

With bingapi.py, we query the rest urls to get the JSON response, which is parsed with simplejson.py. bingapi.py just adds simple niceties like logging and error handling.

Installing bingapi.py

easy_install bingapi

or Svn it from https://svn.uswaretech.com/bingapi/

Using bingapi.py

To use this library, you need to have an Appid from Bing. You can get it from http://www.bing.com/developers/createapp.aspx

The meat of bingapi.py is talk_to_bing function. It takes a query(eg. salsa) and a sources(eg. web) and other optional parameters in extra_args (eg. {'web.offset': 40}) and returns the dictionary of Bing's response.

eg

In [2]: from bingapi import bingapi

In [3]: bing = bingapi.Bing('<Your Appid>')

In [4]: bing.talk_to_bing('salsa', sources='web')
Out[4]: 
..........

In [5]: bing.talk_to_bing('salsa', sources='web', extra_args={'web.offset':40})
Out[5]: 
..........

Class Bing also provides utility functions to do the various types of seraches so you dont have to remember the source type.

The various functions available are,

do_web_search
do_image_search
do_news_search
do_spell_search
do_related_search
do_phonebook_search
do_answers_search

All of them are used similarly.

In [6]: bing.do_web_search('salsa')
Out[6]: 
..........

In [7]: bing.do_image_search('salsa')
Out[7]: 
..............

In [8]: bing.do_answers_search('what is salsa')
Out[8]: 
...............

If you want to use multiple sources in one call you can use talk_to_bing directly as

In [10]: bing.talk_to_bing(query='salsa', sources='web news')
Out[10]:
............

But, but.. Why bing? you ask. Well, other than the fact that bing search is indeed better in some areas, particularly multimedia, bing has fairer usage quota and API restrictions.

Resources


Developing a search mashup? Bing API? Yahoo, Google APIs? We can help.


Related Posts


Can we help you build amazing apps? Contact us today.

Comments

Developer Blog

Bing it on!...

Ten days have passed since we launched the new Bing API, and we are happy to share with you, the developer...

commmenttor
Erik Karulf

Hi All,

Two questions
1) What is the project license?
2) Could you try importing Python 2.6's builtin json module and fall back to simplejson ?

Thanks!

commmenttor
Lakshman

Eric,

The wrapper is Open Source and released under the liberal GPL v3 license.

commmenttor
toxicafunk 13th June, 2009

Hi,

I keep getting this error when using easy_install:

ImportError: No module named ez_setup

seems like you're missing a file.

commmenttor
Pablo 22nd July, 2009

Thanks for this tool but, is there any way to modify the language setting ?
(for eg, I'm in france but sending queries in "english"... the result contains only "french")
any help ?
Thanks

commmenttor
Pablo 23rd July, 2009

Ok, I figured it out.
Just had to add "language:en" at the end of the query.

commmenttor
Jeff 6th Feb., 2012

talk_to_bing returns 10 results by default, or I'm doing something wrong. I was expecting 40. Still, works great. Thanks!

commmenttor
pybing-user 27th June, 2012

Are there plans to update this? With the new Search API 2.0, AppID isn't supported anymore - and you need to use a Account Key instead, and authentication step is very different.

commmenttor
Performance Critique: Nike Air Max Lebron VII

Python Wrapper on Bing API - Agiliq Blog | Django web app development
Performance Critique: Nike Air Max Lebron VII http://www.reptileclassifieds.co.uk/includes/news.asp?id=24

commmenttor
danishoak

The publication all but predicted this year’s brutal winter, which dropped approximately 60 inches of snow on the city.
danishoak http://www.danishoak.com

commmenttor
Fake Oakley Frogskins

Hi, I log on to your blogs regularly. Your humoristic style is witty, keep doing what you're doing!

commmenttor
Asics Femme pas cher

Quand je vois ces six ensemble, je ne peux pas m'empêcher de penser aux champions du Westminster Dog Show. Vous avez races qui semblent complètement différents les uns des autres (labradors, caniches, boxeurs, Dalmatiens), et pourtant ils sont tous les champions.
Asics Femme pas cher http://www.nk987.com/

commmenttor
http://www.maverickscricket.com/?nike-roshe-run-womens

And so once I requested information technology i thought it had been going to be a wonderful however cheaply manufactured bracelet greatest concerning stocking stuffers. Although its prepared wonderfully then is thick hence it really is not really plastic material otherwise conveniently chipped metal. My mother enjoyed things. It is a bit on the slight part so if you have actually a bigger wrist i wouldnt endorse that it but it is therefore value on discount rates!!

commmenttor
Nike free 3.0 womens

Really mother's day present. Though, on bracelet got too lengthy to come, and it arrived following the vacation. My mom indicated that she liked that the bracelet, though I've not really noticed her wear it yet. :-)

commmenttor
Coach Wallets for Men

That headset is since spectacular because into the image. Information technology arrived promptly. I'd suggest choosing a towel more than every single level while you click things off w / a vapor iron. It does not steam outside and merely a steamer. The particular iron ended up being appropriate. It is very delicate, so if you you should not trust yourself with the towel additionally steam iron, therefore take that to a pro. Gorgeous appear.

commmenttor
jordans

The debt scam imposed by Great Britain and Holland money printers was declared null and void. A public assembly has been created to rewrite Iceland's constitution. The area around the mouth can be uneven and liner can more definition and even alter the shape of the lip. For instance, if a person has lips that droop, they can draw and uplifted corner for their lips.

commmenttor
gucci belt cheap

advertising along with reports characteristics that do not appear on the web, you will receive [url=http://www.picketreport.com/suppor.php?p=true-religion-online-outlet]true religion online outlet[/url]
So will this performing artists often be about period, or in a very spacecraft some other place? [url=http://www.picketreport.com/suppor.php?p=cheap-true-religion-jeans-men]cheap true religion jeans men[/url]
(in outdoors tables) [url=http://www.picketreport.com/suppor.php?p=true-religion]true religion[/url]
Individuals for any Risk-free Powerful San Jose, assisting Liccardo regarding Gran 2014: $239,468 in WednesdaySource: Town clerk's workplace. Appointments and figures symbolize most recent studies sent in because of the groups. [url=http://www.picketreport.com/suppor.php?p=true-religion-wholesale]true religion wholesale[/url]
Comes to an end [url=http://www.picketreport.com/suppor.php?p=true-religion-joey]true religion joey[/url]
PALO CEDRO The actual suits have been from the northern, but all the game titles travelled southerly. [url=http://www.picketreport.com/suppor.php?p=true-religion-clothing]true religion clothing[/url]
--- [url=http://www.picketreport.com/suppor.php?p=true-religion-jeans-for-men]true religion jeans for men[/url]
Avery Calhoun became out of your swimming for your remaining time frame being a person this 50 % Man in the moon These types of High School boating company in addition to sought for her teammates. As soon as he or she uncovered all of them, he hugged plus thanked these individuals.

commmenttor
http://www.alhambrasurgerycenter.com/cheapcarshop/MotorcycleSupplies/rpCB6QCcOg/

¥¤¥ª¥ó ¤Ï27ÈդδóÒý¤±áá¡¢1Ô¤θśr¤ò°k±í¤·¡¢Í¬Ô¤ÎßB½Y†Ó˜I…§Òæ¤ÏÇ°ÄêͬÔ±È81‰ˆ¤Î5122ƒ|ƒÒ¤Ë¤Ê¤Ã¤¿¤È¤·¤¿¡£1Ô¶Ȥϡ¢¥¯¥ê¥¹¥Þ¥¹¤äÄêÄ©Äêʼ¡¢³õ‰Ó¤ê¥»©`¥ë¤ä¥«©`¥É»á†TŒÏó¤ÎØœ´ÙÆó»­¤ËÈ¡¤ê½M¤ß¡¢Ê˜I¤Ç¤Ï¡¢šÝΤεÍϤȤȤâ¤ËÒÂÁϤò¤Ï¤¸¤á¤È¤¹¤ë¼¾¹É̲ĤòÉì¤Ð¤·¡¢Ê˜I¤Ç¤Ï¡¢åÎï¤ä¤ª×£¤¤ÓäÎʳ²Ä¤¬ÉìéL¤·¡¢Ð¡Ð͵êʘI¤È¤È¤â¤Ë¡¢Æ·¤¾¤í¤¨¤òŠ»¯¤·¤¿ÄÚʳÉÌÆ·¤ä¥Ç¥¶©`¥ÈÎÉìéL¤¬¼ÄÓ뤷¤¿¡£¾tºÏ½ðÈÚʘI¤Ç¤Ï¥«©`¥É¥·¥ç¥Ã¥Ô¥ó¥°È¡’Q¸ß¤òÉì¤Ð¤·¤¿¤Û¤«¡¢¥«©`¥É¥­¥ã¥Ã¥·¥ó¥°¤¬Ç°Äê¤òÉϻؤäÆÉìéL¤·¤¿¡£

commmenttor
http://www.kgmotor.no/shopjewelryol/MCohen/1NfkZLACUo/

¥¹¥×©`¥óÃÀÈݤò¤Ï¤¸¤á¡¢ëjÕI¤ä¤ÇÔ’î}¤ÎÃÀÈÝÑо¿¼Ò¡¢Ð¡ÁÖ¤Ò¤íÃÀ¤µ¤ó¤¬¥×¥í¥Ç¥å©`¥¹¤¹¤ë¥»¥Ö¥ó¥Õ¥í©`¤è¤ê¡¢¥ª¥¤¥ë¤ÎÉì¤Ó¤ä¼¡¤Ê¤¸¤ß¤Ë¤âØµ×µÄ¤Ë¤³¤À¤ï¤Ã¤¿¡¢¤ªî†¤À¤±¤Ç¤Ï¤Ê¤¯¥Ü¥Ç¥£¤òº¬¤ó¤À¥È©`¥¿¥ë¥±¥¢¤ò¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡°¥Ï©`¥Ö¥µ©`¥­¥å¥ì¥¤¥È¥ª¥¤¥ë£¨¥Õ¥§¥¤¥¹¥Ü¥Ç¥£ÓÃ¥±¥¢¥ª¥¤¥ë£©¡±¤È¡¢¥Õ¥ë©`¥Ä¤Î{¤ß¤Ë¤è¤ë¥¨¥­¥¹¤ä¡¢¥Õ¥é¥ï©`¥·¥È¥é¥¹¤ÎÏã¤ê¤Ë¤³¤À¤ï¤Ã¤¿¡¢¥á¥¤¥¯¤ÎÉϤ«¤é¤Ç¤âʹ¤¨¤ë¡°¥Ó¥å©`¥Æ¥£©`¥Õ¥ë©`¥Ä¥ß¥¹¥È£¨¥ß¥¹¥È×´»¯»’Ë®£©¡±¤Î¥»¥Ã¥È¤Ç¤¹9/22 SSVý¸ñ£ºË°Þz8,450

commmenttor
http://www.dacel.com.tr/honorwatch/DG/qvsBmlfk14/

まだなのマイヒーロー!?あきさかあさひ

commmenttor
Cheap Nike air max womens UK

I have this particular headphonesfor the the mom for the moms time, to she definitely loved that it! It really is truly cute headphonesand suggesting regarding the card that will goes in the container is really sentimental!! As well as the good of the beads was very good!

commmenttor
yoox piumini moncler

The Republican intentions to expose his / her hint from their state’s [url=http://www.cddor.com/feature.php?id=cardigan-moncler]cardigan moncler[/url]
Just how financial institutions identify secondly work revenue [url=http://www.cddor.com/feature.php?id=piumino-moncler-donna]piumino moncler donna[/url]
If: 8 w.meters. Mondy [url=http://www.cddor.com/feature.php?id=outlet-padova-moncler]outlet padova moncler[/url]
"Some mounts absolutely should not get a mile and a half," Gowan said, "and a number of farm pets really enjoy this." [url=http://www.cddor.com/feature.php?id=giubbino-moncler-prezzo]giubbino moncler prezzo[/url]
Adhere to all of us with [url=http://www.cddor.com/feature.php?id=piumino-moncler-milano]piumino moncler milano[/url]
The state of arkansas freshman right-hander Chris Oliver involving Farmington through Shiloh Christian increased for you to 8-4, organizing some sort of four-hitter by way of Some 1 Several innings Wed, making it possible for just one single function, unearned, singled property inside in 7th place in opposition to left-handed reliever Erika Gunn. [url=http://www.cddor.com/feature.php?id=padova-outlet-moncler]padova outlet moncler[/url]
Your Expendables 3 is not the state selection during Cannes, nonetheless its celebrities have made one of the most in their Cannes go to showing up for the Riviera within fish tanks.

commmenttor
Cartier Love Bracelet

Good mother's day present. Still, ones bracelet got as well longer in order to show up, and it appeared after the vacation. The mother conveyed in which she liked the bracelet, yet I have never observed this girl use it still. :-)

commmenttor
Jordan AJ 1 Mid - Girls' Toddler

05/16/2014 2009:24:Forty-six 'm PDT(Contra Costa CHP/BCN)Connected StoriesMay 12: [url=http://www.owenspark.net/product.php?product/model:197337/sku:84482/adidas-originals-samoa-girls-preschool/pink/black/?cm=searchgirlsshoes]adidas Originals Samoa - Girls' Preschool[/url]
"We became this 15 seed starting in 2009 as well as little ones decided not to realize why,In . San Leandro guru Robert Bungarz stated. "My response seemed to be "Go verify them improper.No And that we went out and don't enjoy properly and got beat rather handily. Same thing at this moment, 'Go verify that we are greater than your 17 seed.Ha This is certainly ancient for people like us." [url=http://www.owenspark.net/product.php?product/model:211074/sku:KV574RRI/new-balance-574-hook-and-loop-girls-toddler/red/maroon/?cm=searchgirlsshoes]New Balance 574 Hook and Loop - Girls' Toddler[/url]
Get in touch with Sharon Noguchi on 408-271-3775. Abide by the girl's in . [url=http://www.owenspark.net/product.php?product/model:218120/sku:54409100/nike-air-maximize-boys-grade-school/white/silver/?cm=searchboysshoes]Nike Air Maximize - Boys' Grade School[/url]
Precisely what Different Can assist? [url=http://www.owenspark.net/product.php?product/model:205798/sku:86787-05/puma-voltaic-3-boys-preschool/blue/light-green/?cm=searchboysshoes]PUMA Voltaic 3 - Boys' Preschool[/url]
Metropolis is providing four week-long ideologies to get golfing, flag soccer as well as other sports. [url=http://www.owenspark.net/product.php?product/model:221012/sku:6561-001/under-armour-spine-surge-boys-preschool/black/red/?cm=searchboysshoes]Under Armour Spine Surge - Boys' Preschool[/url]
Font Re-size [url=http://www.owenspark.net/product.php?product/model:202799/sku:350N3591/asics-gt-1000-2-girls-preschool/pink/light-green/?cm=searchgirlsshoes]ASICS� GT-1000 2 - Girls' Preschool[/url]
Font Resize [url=http://www.owenspark.net/product.php?product/model:194590/sku:738691/converse-pc-primo-crayola-boys-toddler/grey/light-green/?cm=searchboysshoes]Converse PC Primo Crayola - Boys' Toddler[/url]
Cespedes made it 5-3 together with his double, and Alberto Callaspo extra a two-run dual.

commmenttor
adidas Originals Samoa - Boys' Toddler

many thanks for knowing and service. [url=http://www.owenspark.net/product.php?product/model:161443/sku:54461001/nike-team-hustle-d-5-boys-grade-school/black/white/?cm=searchboysshoes]Nike Team Hustle D 5 - Boys' Grade School[/url]
Thursday, Could 25, 2014 | Ten:Eleven a.meters. [url=http://www.owenspark.net/product.php?product/model:210205/sku:D7210/adidas-f50-adizero-trx-fg-boys-preschool/light-blue/white/?cm=searchboysshoes]adidas F50 adiZero TRX FG - Boys' Preschool[/url]
05/30/2014 02:Forty three:Thirty three Evening PDT [url=http://www.owenspark.net/product.php?product/model:229304/sku:0022-FBL/converse-2-pack-chucks-booties-boys-infant/light-blue/gold/?cm=searchboysshoes]Converse 2 Pack Chucks Booties - Boys' Infant[/url]
05/31/2014 August:27:24 In the afternoon PDTUpdated: [url=http://www.owenspark.net/product.php?product/model:219012/sku:54252800/nike-hyperdunk-2014-boys-grade-school/orange/black/?cm=searchboysshoes]Nike Hyperdunk 2014 - Boys' Grade School[/url]
Ukrainian terrain. Moscow place Yarosh around the worldwide [url=http://www.owenspark.net/product.php?product/model:203902/sku:87212009/jordan-retro-10-girls-preschool/grey/black/?cm=searchgirlsshoes]Jordan Retro 10 - Girls' Preschool[/url]
Simply no. 16 St. Lawrence (15-4) with No. Just one Pacific Grove (19-6) [url=http://www.owenspark.net/product.php?product/model:209183/sku:159600/nike-ctr360-libretto-iii-tf-boys-toddler/orange/black/?cm=searchboysshoes]Nike CTR360 Libretto III TF - Boys' Toddler[/url]
However, Negron do service an idea that's all about replication, Sen. Ruben Thrasher utes proposal to build different executive schools in California Talk about College in addition to Fl A&M College or university, which talk about one program in Tallahassee. [url=http://www.owenspark.net/product.php?product/model:42116/sku:232569/adidas-originals-samoa-boys-preschool/black/red/?cm=searchboysshoes]adidas Originals Samoa - Boys' Preschool[/url]
The newest image resolution added words that will eliminates that will mobility. Currently the petition and the city proposals claim critically the exact same thing in several words. [url=http://www.owenspark.net/product.php?product/model:215373/sku:41754013/nike-sb-stefan-janoski-boys-toddler/grey/light-green/?cm=searchboysshoes]Nike SB Stefan Janoski - Boys' Toddler[/url]
Pm John Muscat mentioned currently which Saturday's Western elections wasn't no more than choosing MEPs but will also with regards to evaluating in between their efficiency understanding that regarding Resistance boss Simon Busuttil.

commmenttor
Cheap Nike Air Max

I had gotten this particular headphonesof the mother towards moms day, and she absolutely adored it! It really is truly sweet headphonesand the saying on the card that will come into the container is really sentimental!! As well as the excellence of beads was very good!

commmenttor
michael kors outlet

I obtained this trying to find a very good present for my mother. That the headphone came within a breathtaking purple tied up package. This is ideal searching gifts below your xmas tree!! Your headphone even seemed striking, still our mama are huge boned as well as the headphone is some tight, however its a great present! I love information technology.

commmenttor
Cheap Nike Air Max UK

I bought our searching for a great gift for my mama. On headphone came in a striking purple tied container. This is the best searching gifts underneath on xmas tree!! Ones headphone even looked beautiful, but my mama is actually larger boned and headphone was a little tight, then again it really is a great gift! I prefer information technology.

commmenttor

Reactions

mdipierro

The great thing about this is that the code (bingapi.py) consists of 64 lines total of pure python code with no dependencies. Works out of the box with any Python code.

This comment was originally posted on Reddit

jimmybot

Haven’t been testing out Bing like some of the others out there. Just took a quick look at Bing news search–they incorporate news results with top blogs? That seems interesting to me. Is that unique, anyone know? I don’t see it in Google News.

This comment was originally posted on Hacker News

jerf

OK, great, but can we please avoid the "Bing API for X" flurry from here on out? Yes, I’m sure there will soon be Bing APIs for Clojure, Haskell, Perl, PHP, C, C++, and so on and so forth.If I want them, I’ll Google for them.

This comment was originally posted on Hacker News

jmatt

Agreed.As for the actual api it’s here:

http://msdn.microsoft.com/en-us/library/dd251056.aspx

This comment was originally posted on Hacker News

dnene

Python bing api : http://bit.ly/xhiBN

This comment was originally posted on Twitter

rubayeet

Python bing api : http://bit.ly/xhiBN (via@dnene)

This comment was originally posted on Twitter

mandarvaze

Python Wrapper on Bing API — (via@dnene) http://ff.im/-6u8sm

This comment was originally posted on Twitter

Post a comment Name :

Email :

Your site url:

Comment :

© Agiliq, 2009-2012