我正在為學校構建一個列出狗品種的 flutter 應用程式。我想知道是否可以為谷歌搜索查詢下拉“關于部分”。我正在使用顫振/飛鏢,但我認為這個問題與語言無關,我只是想知道這是否可能。這就是我要說的:

我想抓住“關于”標題下的段落。這可能嗎?
uj5u.com熱心網友回復:
您必須從 Google https://developers.google.com/knowledge-graph使用此 API
uj5u.com熱心網友回復:
但是,有很多方法可以做到這一點。您可以使用這個名為SerpApi 的API 的一種方法
這將回傳結果 Json
只需注冊此服務。和http包你可以得到這樣的結果
import 'package:http/http.dart' as http;
var url = Uri.parse('https://serpapi.com/search');
var query = "Samoyed" // Your query;
var response = await http.get(url "?q=$query&google_domain=google.com&api_key=secret_api_key");
print(response.body);
你會得到
"knowledge_graph":
{
"title":
"Samoyed",
"type":
"Dog breed",
"header_images":
[
{
"image":
"https://serpapi.com/searches/619669ffc47d3ccfb5511aa1/images/1dbd475a36109a83173d2d6a380adb0cd740843c4a06be6455a87b252b4811b3f717889baa84eb34.jpeg",
"source":
"https://en.wikipedia.org/wiki/Samoyed_dog"
},
{
"image":
"https://serpapi.com/searches/619669ffc47d3ccfb5511aa1/images/1dbd475a36109a83173d2d6a380adb0cd740843c4a06be6477e61734e5c35299fd9ba84a832499c2.jpeg",
"source":
"https://www.akc.org/dog-breeds/samoyed/"
},
{
"image":
"https://serpapi.com/searches/619669ffc47d3ccfb5511aa1/images/1dbd475a36109a83173d2d6a380adb0cd740843c4a06be641d71587a667af36fd5c22ede97ad0d5d.jpeg",
"source":
"https://www.thesprucepets.com/samoyed-dog-breed-profile-4586270"
},
{
"image":
"https://serpapi.com/searches/619669ffc47d3ccfb5511aa1/images/1dbd475a36109a83173d2d6a380adb0cd740843c4a06be6407d380d689b958ece6cfa86598a2b35e.jpeg",
"source":
"https://www.rover.com/blog/samoyed-puppies-complete-guide/"
},
{
"image":
"https://serpapi.com/searches/619669ffc47d3ccfb5511aa1/images/1dbd475a36109a83173d2d6a380adb0cd740843c4a06be64097c7c54fd3dce6ea08aeb17527d8bfa.jpeg",
"source":
"https://www.dailypaws.com/dogs-puppies/dog-breeds/samoyed"
},
{
"image":
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTDUBrb001EttjCvMAByRCKQvioc2KHy6rD7McCmeJ1wg&s",
"source":
"http://www.vetstreet.com/dogs/samoyed"
}
],
"description":
"The Samoyed is a breed of medium-sized herding dogs with thick, white, double-layer coats. They are a spitz-type dog which takes its name from the Samoyedic peoples of Siberia.",
"source":
{
"name":
"Wikipedia",
"link":
"https://en.wikipedia.org/wiki/Samoyed_dog"
},....
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/360805.html
