How to obtain a feed of comments entered through the 'chat' box during a YouTube live broadcast?

前端 未结 3 1893
生来不讨喜
生来不讨喜 2020-11-29 03:39

The YouTube API enables users to obtain a comments feed, e.g. via https://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments?orderby=published.

Howeve

3条回答
  •  一个人的身影
    2020-11-29 04:04

    I came Up with a Basic Script for this

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Net;
    using System.IO;
    using System.Text.RegularExpressions;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    
    namespace test
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                Starting();
            }
    
            public void Starting()
            {
                IWebDriver driver = new ChromeDriver();
                driver.Navigate().GoToUrl("https://www.youtube.com/watch?v=Yu5Om0SH3No");
    
                Thread.Sleep(10000);
    
                //Find Comments
                IWebElement element = driver.FindElement(By.ClassName("comment-text"));
                Console.WriteLine("Text: " + element.Text);
    
                //Find User names
                IWebElement element2 = driver.FindElement(By.XPath(".//*[@class='g-hovercard yt-uix-sessionlink yt-user-name']"));
                Console.WriteLine("Username: " + element2.Text);
    
    
    
            }
        }
    }
    

    Will Need More Hours Of Work To Make It Read the Page as The Comments Flow.

提交回复
热议问题