我正在构建一个项目,该项目从用户那里获取一个术语,然后执行谷歌搜索并以 json 格式返回标题列表。
我正在使用 serpwow API 来执行谷歌搜索并试图解析响应。
但是,我收到错误消息:
panic: interface conversion: interface {} is []interface {}, not map[string]interface {}.
Run Code Online (Sandbox Code Playgroud)
我查看了各种表格并试图了解映射的工作原理,但我不确定为什么在这种情况下,我的映射不起作用。有机结果表如下所示:
"organic_results": [
{
"position": 1,
"title": "The 10 Best Pizza Places in Dublin - TripAdvisor",
"link": "https://www.tripadvisor.ie/Restaurants-g186605-c31-Dublin_County_Dublin.html",
"domain": "www.tripadvisor.ie",
"displayed_link": "https://www.tripadvisor.ie › ... › County Dublin › Dublin",
"snippet": "Best Pizza in Dublin, County Dublin: Find TripAdvisor traveller reviews of Dublin Pizza places and search by price, location, and more.",
"prerender": false,
"snippet_matched": [
"Pizza",
"Pizza"
],
"cached_page_link": "https://webcache.googleusercontent.com/search?q=cache:OS-Ar9hB_ngJ:https://www.tripadvisor.ie/Restaurants-g186605-c31-Dublin_County_Dublin.html+&cd=4&hl=en&ct=clnk&gl=ie",
"related_page_link": …Run Code Online (Sandbox Code Playgroud)