在現代Web應用程序開發中,使用JSON(JavaScript Object Notation)通常是非常常見的。JSON是一種輕量級的數據交換格式,它使用易于理解的文本,并且在各種編程語言之間無縫傳遞數據。而Google正是一家擁有龐大數據的企業,它提供API來獲取數據并將其返回為JSON格式。
{ "kind": "customsearch#search", "url": { "type": "application/json", "template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&cx={cx}&client={clientName}&num={count?}&start={startIndex?}&lr={language?}&output={outputEncoding?}&safe={safe?}&googlehost={googleHost?}&filter={filter?}&gl={gl?}&cr={cr?}&sort={sort?}" }, "queries": { "nextPage": [ { "title": "Google Custom Search - Google", "totalResults": "69300000000", "searchTerms": "Google", "count": 10, "startIndex": 11, "inputEncoding": "utf8", "outputEncoding": "utf8", "safe": "off", "cx": "017576662512468239146:omuauf_lfve", "searchType": "image" } ], "request": [ { "title": "Google Custom Search - Google", "totalResults": "69300000000", "searchTerms": "Google", "count": 10, "startIndex": 1, "inputEncoding": "utf8", "outputEncoding": "utf8", "safe": "off", "cx": "017576662512468239146:omuauf_lfve", "searchType": "image" } ] }, "context": { "title": "Google" }, "searchInformation": { "searchTime": 0.558252, "formattedSearchTime": "0.56", "totalResults": "69300000000", "formattedTotalResults": "69,300,000,000" }, "items": [ { "kind": "customsearch#result", "title": "Google", "htmlTitle": "Google", "link": "http://www.google.com/", "displayLink": "www.google.com", "snippet": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking?...", "htmlSnippet": "Search the world's information, including webpages, images, videos and more.Googlehas many special features to help you find exactly what you're looking ...", "cacheId": "zhw7xYfGsmAJ", "formattedUrl": "www.google.com/", "htmlFormattedUrl": "www.google.com/", "pagemap": { "metatags": [ { "viewport": "width=device-width, initial-scale=1", "google": "notranslate", "format-detection": "telephone=no" } ] } } ] }
在上面的代碼中,我們可以看到"kind": "customsearch#search"
,這是用于自定義搜索的特定API的JSON響應。在"queries"
對象中,我們可以看到這是一個帶有分頁的搜索結果。在"searchInformation"
下,我們可以看到搜索時間、總結果計數、格式化計數等詳細信息。同時,在"items"
下,我們可以看到Google為給定搜索詞返回的結果數組。
上一篇python 批量化網頁
下一篇mysql單獨一個可以嗎