さて、いくつかの方法があります。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'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">·</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 を変更します。