Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
880 views
in Technique[技术] by (71.8m points)

json - Google's "define: " through an API?

I want to get the result of searches that use special features in Google, like "define: [phrase]" and I can't seem to find relevant information about this.

Does anyone knows where I can get the data in JSON format (like the rest of Google's APIs) without scraping the results page manually?

Thanks, Eli

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I wish I had not set a bounty for this, because I stumbled upon the answer a few days later and it is really simple.

Here is URL to call if you want a definition to love:

http://www.google.com/dictionary/json?callback=a&sl=en&tl=en&q=love

You will get a response stream containing JSONP, with the following contents ("prettified" for learning purposes, API returns all in one line):

a(
    {
       "query":"love",
       "sourceLanguage":"en",
       "targetLanguage":"en",
       "primaries":[
          {
             "type":"headword",
             "terms":[
                {
                   "type":"text",
                   "text":"love",
                   "language":"en",
                   "labels":[
                      {
                         "text":"Noun",
                         "title":"Part-of-speech"
                      }
                   ]
                },
                {
                   "type":"phonetic",
                   "text":"/lé?v/",
                   "language":"und"
                },
                {
                   "type":"sound",
                   "text":"http://www.gstatic.com/dictionary/static/sounds/de/0/love.mp3",
                   "language":"und"
                }
             ],
             "entries":[
                {
                   "type":"related",
                   "terms":[
                      {
                         "type":"text",
                         "text":"loves",
                         "language":"und",
                         "labels":[
                            {
                               "text":"plural"
                            }
                         ]
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"An intense feeling of deep affection",
                         "language":"en"
                      }
                   ],
                   "entries":[
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"babies fill parents with intense feelings of x3cemx3elovex3c/emx3e",
                               "language":"en"
                            }
                         ]
                      },
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"their x3cbx3ex3cemx3elovex3c/emx3e forx3c/bx3e their country",
                               "language":"en"
                            }
                         ]
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"A deep romantic or sexual attachment to someone",
                         "language":"en"
                      }
                   ],
                   "entries":[
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"it was x3cemx3elovex3c/emx3e at first sight",
                               "language":"en"
                            }
                         ]
                      },
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"they were both x3cbx3ein x3cemx3elovex3c/emx3e withx3c/bx3e her",
                               "language":"en"
                            }
                         ]
                      },
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"we were slowly x3cbx3efalling in x3cemx3elovex3c/emx3ex3c/bx3e",
                               "language":"en"
                            }
                         ]
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"A personified figure of x3cemx3elovex3c/emx3e, often represented as Cupid",
                         "language":"en"
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"A great interest and pleasure in something",
                         "language":"en"
                      }
                   ],
                   "entries":[
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"his x3cbx3ex3cemx3elovex3c/emx3e forx3c/bx3e football",
                               "language":"en"
                            }
                         ]
                      },
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"we share a x3cbx3ex3cemx3elovex3c/emx3e ofx3c/bx3e music",
                               "language":"en"
                            }
                         ]
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"Affectionate greetings conveyed to someone on onex27s behalf",
                         "language":"en"
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"A formula for ending an affectionate letter",
                         "language":"en"
                      }
                   ],
                   "entries":[
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"take care, lots of x3cemx3elovex3c/emx3e, Judy",
                               "language":"en"
                            }
                         ]
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"A person or thing that one x3cemx3elovesx3c/emx3e",
                         "language":"en"
                      }
                   ],
                   "entries":[
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"she was x3cbx3ethe x3cemx3elovex3c/emx3e of his lifex3c/bx3e",
                               "language":"en"
                            }
                         ]
                      },
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"their two great x3cemx3elovesx3c/emx3e are tobacco and whiskey",
                               "language":"en"
                            }
                         ]
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"A friendly form of address",
                         "language":"en"
                      }
                   ],
                   "entries":[
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"itx27s all right, x3cemx3elovex3c/emx3e",
                               "language":"en"
                            }
                         ]
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"Used to express affectionate approval for someone",
                         "language":"en"
                      }
                   ],
                   "entries":[
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"donx27t fret, therex27s a x3cemx3elovex3c/emx3e",
                               "language":"en"
                            }
                         ]
                      }
                   ]
                },
                {
                   "type":"meaning",
                   "terms":[
                      {
                         "type":"text",
                         "text":"(in tennis, squash, and some other sports) A score of zero; nil",
                         "language":"en"
                      }
                   ],
                   "entries":[
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"x3cemx3elovex3c/emx3e fifteen",
                               "language":"en"
                            }
                         ]
                      },
                      {
                         "type":"example",
                         "terms":[
                            {
                               "type":"text",
                               "text":"he was down two sets to x3cemx3elovex3c/emx3e",
                               "language":"en"
                            }
                         ]
                      }
                   ]
                }
             ]
          },
          {
             "type":"headword",
             "terms":[
                {
                   "type":"text",
                   "text":"love",
                   "language":"en",
                   "labels":[
                      {
                         "text":"Verb",
            

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...