0

我正在尝试制作一个使用它的 v3 API 搜索 youtube 的简单脚本,但是对于特定的关键字,我没有得到与 youtube.com 相同的视频。

这是我正在使用的网址:https://www.googleapis.com/youtube/v3/search?order=relevance&regionCode=US&type=video&part=snippet&maxResults=10&q=test&key=*****

与 youtube.com 相比,API 的准确性如何?

4

2 回答 2

0

我正在用我的代码测试其他地区的搜索过滤器,因为我在阿根廷,并且试图只获取 3 个视频。

我对 API 和 YouTube 页面的结果相同。

GET https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=3&order=relevance&q=test&regionCode=AR&type=video&key={YOUR_API_KEY}

我得到这个回应:

200 OK

- Show headers -

{
 "kind": "youtube#searchListResponse",
 "etag": "\"GGhQgtOz7wdV-KaTX3akpjqktXI/ZQcMULMzhl7jNZmXCsem5ycElvI\"",
 "pageInfo": {
  "totalResults": 1000000,
  "resultsPerPage": 3
 },
 "nextPageToken": "CAMQAA",
 "items": [
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "nCgQDjiotG0"
   },
   "kind": "youtube#searchResult",
   "etag": "\"GGhQgtOz7wdV-KaTX3akpjqktXI/4xgmXYRPkRjv8kxP_M5CKZQM2GM\"",
   "snippet": {
    "publishedAt": "2010-05-04T00:49:30.000Z",
    "channelId": "UCL8ZULXASCc1I_oaOT0NaOQ",
    "title": "Google Chrome Speed Tests",
    "description": "These speed tests were filmed at actual web page rendering times. If you're interested in the technical details, read on! Equipment used ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/nCgQDjiotG0/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/nCgQDjiotG0/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/nCgQDjiotG0/hqdefault.jpg"
     }
    }
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "N7-T53_pOSM"
   },
   "kind": "youtube#searchResult",
   "etag": "\"GGhQgtOz7wdV-KaTX3akpjqktXI/T1_ucgK_momRYuuh8o4LvRpJHWM\"",
   "snippet": {
    "publishedAt": "2012-10-03T21:40:01.000Z",
    "channelId": "UCOmcA3f_RrH6b9NmcNa4tdg",
    "title": "Always On - Torture testing the iPhone 5 Ep 16",
    "description": "cnet.com The iPhone 5 enters the torture chamber, the Tesla S gets unboxed, the Galaxy S3 is thrown in the washing machine, and Molly Wood sets ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/N7-T53_pOSM/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/N7-T53_pOSM/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/N7-T53_pOSM/hqdefault.jpg"
     }
    }
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "ubNF9QNEQLA"
   },
   "kind": "youtube#searchResult",
   "etag": "\"GGhQgtOz7wdV-KaTX3akpjqktXI/NM08y0TtHGe2IYmzq8XNDhy6WhY\"",
   "snippet": {
    "publishedAt": "2008-11-03T17:49:54.000Z",
    "channelId": "UCFsK_jxE6BghGx4d2QJLJzQ",
    "title": "Test Your Awareness : Whodunnit?",
    "description": "Test your Awareness with Do The Test's Whodunnit. Who Killed Lord Smithe? TFL cycling safety advert! How observant are you? How did you do? www ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/ubNF9QNEQLA/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/ubNF9QNEQLA/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/ubNF9QNEQLA/hqdefault.jpg"
     }
    }
   }
  }
 ]
}

在 YouTube 页面中,我得到了相同的结果:

Google Chrome Speed Tests
by Google Chrome•2 years ago•6,721,020 views
These speed tests were filmed at actual web page rendering times. If you're interested in the technical details, read on ...
HDCC
31:01  
Always On - Torture testing the iPhone 5 Ep 16
by CNETTV•4 months ago•267,084 views
Season 2•Episode 16•Always On
cnet.com The iPhone 5 enters the torture chamber, the Tesla S gets unboxed, the Galaxy S3 is thrown in the washing machine ...
HD
1:55  
Test Your Awareness : Whodunnit?
by dothetest•4 years ago•3,477,032 views
Test your Awareness with Do The Test's Whodunnit. Who Killed Lord Smithe? TFL cycling safety advert! How observant are you ...
HD
于 2013-02-06T00:16:17.040 回答
0

API 应与网站具有相同的准确性。您是否使用相同的用户帐户进行测试?你能举一些具体的例子来跟进吗?

于 2013-02-05T19:40:54.147 回答