0

I'm using Bing cse to receive information in my program and I am having trouble prasing the whole bing search data.

there is a json format example:

{u'Web': [{
    u'Description': u"Discription", 
    u'DisplayUrl': u'DisplayedUrl', 
    u'ID': u'Id', 
    u'Title': u'Title', 
    u'Url': u'Url', 
    u'__metadata': {
        u'type': u'WebResult', 
        u'uri': u"https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/ExpandableSearchResultSet(guid'XXXXX')/Web?$skip=0&$top=1"
    }
}]}

I have DisplayUrl, Title, discription but i cant figure out how to take the sub_title of the query. the sub_title is the short discription below the title(not always appears)

the search results in "real" bing search is displayed in the following way:

Title
DisplayUrl
Sub_Title
Discription

rudolph9
  • 8,021
  • 9
  • 50
  • 80
OriK
  • 293
  • 1
  • 3
  • 13

1 Answers1

0

Assuming you saved that structure as the variable foo, the following python code will iterate over the list of items (which you only gave one example of), and print out the values for each item:

for item in foo.get(u'Web', []):  # Iterate over the list under the dictionary key "Web"
    print item.get(u'Title'), item.get(u'DisplayUrl'), item.get(u'Sub_Title'), item.get(u'Description')

Title DisplayedUrl None Discription

You will notice that item.get(u'Sub_Title') will return None in this case, but would return valid data if the dictionary contains that key.

VooDooNOFX
  • 4,674
  • 2
  • 23
  • 22
  • Yeah, thats my problem.. i don't receive any sub title in the results structure.. I might need to configure something in order to get it? If i do, what I need to configure? Thanks – OriK Nov 13 '13 at 05:37
  • I looked a bit in the bing search api schema and and there is no mention of sub_title. I.E https://skydrive.live.com/view.aspx?resid=9C9479871FBFA822!109&app=Word&authkey=!ACvyZ_MNtngQyCU --- page 7 – OriK Nov 13 '13 at 07:40