2

ビデオからすべてのコメントを取得し、コメントを投稿したすべてのユーザーを取得できるツールを作成して、景品を簡単にしようとしています

現在、Youtube APIを使用しています

gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments?v=2&alt=json&start-index=1

すべてのコメントを取得するために、毎回開始インデックス (1、22、44、66 など) をインクリメントする単純なループを作成するだけです。

問題は、ビデオに 1000 を超えるコメントがあるため、たとえば、これが機能しないことです: gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments?v=2&alt=json&start-index=1100

http://pastebin.com/ypLrFmTG

Youtube ビデオにコメントを投稿したすべてのユーザーを取得する方法はありますか? Youtube api の仕組みを理解するために数時間これに取り組みましたが、この問題によりすべてが役に立たなくなります

これらのページのコンテンツを取得するには、curl または別の方法を使用する必要があります: youtube.com/all_comments?threaded=1&v=VIDEO_ID&page=x

4

1 に答える 1

3

さて、いくつかの方法があります。1つ目は、あなたが投稿したsandraciresのリンクです。それらの JavaScript を表示してから分割すると (またはフィドラーでトラフィックを監視するだけ)、そのサイトの comments.php ページにアクセスし、ページ番号を渡します。URL の形式はhttp://www.sandracires.com/en/client/youtube/comments.php?v=videoID&page=1です。ただし、その合法性については確信が持てないため、お勧めしません。

私はYoutube自体でFiddlerを使用しましたが、これが私が思いついたものです。

http://youtube.com/watch_ajax?action_get_comments=1&v=videoID&p=4&commentthreshold=-5&commenttype=everything&last_comment_id=teKFzQ8cbHNiI0ouIIqSS7lHeH2TZ8eWGlW-0D0Fx5U&page_size=500&source=w

  • v = ビデオ ID
  • p = ページ番号
  • コメントのしきい値 = ???
  • commenttype = コメント タイプ (すべてが私が知っている唯一の列挙値です)
  • last_comment_id = 読み込む直前のコメント
  • page_size = 返されるコメントの量
  • ソース = ??? (ウェブの場合もあるかもしれません)

source パラメータなどを削除できる場合があります。

これらがすべて正しいかどうかは完全にはわかりません。p はページ番号だと思います。これにより、パラメーターなしでコメントを取得できlast_comment_idます(このように機能しています)。またlast_comment_id、結果の XML を解析して?lc=LASTCOMMENTIDHERE.

一度に最大500個あるようです。はい、501 を試しました。前述のとおり、データは XML 形式で返されます。各コメントは次のようになります。

<div class="content clearfix">
  <p class="metadata">
    <span class="author ">
      <a href="/user/mindmonkey00" class="g-hovercard yt-uix-sessionlink yt-user-name " data-sessionlink="ei=-LFcUvCPNsn-sAf7jIGgAg" dir="ltr" data-ytid="UCAufDxGRQh_LlF5tD6StNtw" data-name="">mindmonkey00</a>
    </span>
      <span class="time" dir="ltr">
        <a dir="ltr" href="http://www.youtube.com/comment?lc=teKFzQ8cbHNkP8a89kiIEtWqiTRiAkKtSnvEHB_hXG4">
          3 weeks ago
        </a>
      </span>
  </p>


  <div class="comment-text" dir="ltr">
    <p>You didn&#39;t answer my question?</p>

  </div>

  <div class="comment-actions">
    <button onclick=";return false;" type="button" class="start comment-action create-channel-lightbox yt-uix-button yt-uix-button-link yt-uix-button-size-default" data-upsell="comment" role="button"><span class="yt-uix-button-content">Reply </span></button>
    <span class="separator">&middot;</span>


    <span ><button title="Vote Up" onclick=";return false;" type="button" class="start comment-action-vote-up comment-action yt-uix-button yt-uix-button-link yt-uix-button-size-default yt-uix-button-has-icon yt-uix-tooltip yt-uix-button-empty" data-tooltip-show-delay="300" data-action="vote-up" role="button"><span class="yt-uix-button-icon-wrapper"><img class="yt-uix-button-icon yt-uix-button-icon-watch-comment-vote-up" src="//s.ytimg.com/yts/img/pixel-vfl3z5WfW.gif" alt="Vote Up" title=""></span></button></span><span ><button title="Vote Down" onclick=";return false;" type="button" class="end comment-action-vote-down comment-action yt-uix-button yt-uix-button-link yt-uix-button-size-default yt-uix-button-has-icon yt-uix-tooltip yt-uix-button-empty" data-tooltip-show-delay="300" data-action="vote-down" role="button"><span class="yt-uix-button-icon-wrapper"><img class="yt-uix-button-icon yt-uix-button-icon-watch-comment-vote-down" src="//s.ytimg.com/yts/img/pixel-vfl3z5WfW.gif" alt="Vote Down" title=""></span></button></span>
  </div>

</div>

Youtube の API ルールを回避しようとすると、このプロセスを時々やり直す必要があることに注意してください。彼らはおそらく URL を変更します。

于 2013-10-15T03:37:14.267 に答える