跳到正文
DEV Community· Joshua Smith·· 3 小時前AI 評分50

從同領域熱門影片的觀眾提問中發掘下一個影片題材

Find your next video ideas in the questions viewers ask under the top videos in your niche

AI 導讀

Joshua Smith提供一套從同領域熱門 YouTube 影片留言中抽取、分組和排序觀眾問題,以尋找影片題材的方法。流程建議挑選 10 至 20 條熱門、入門或教學影片,依相關度收集最多 300 則留言而不含回覆,再按不同提問者人數及喜歡數排列問題羣組。

正文

The comments under the most-watched videos on a topic are full of questions the video did not answer. Each one is a viewer telling you what they searched for next. This post turns those comments into a ranked list of questions: find the videos, collect their top comments, pull out the questions, group them by subject, and count how many different people asked.

Which videos to read

You want videos where the audience is the audience you want to reach:

  • The most-viewed videos on the topic, not only the newest. They have the most comments and they define what people already know.
  • Beginner and how-to videos, where people get stuck and ask.
  • Your competitors' most popular uploads, if you have specific rivals.

Ten to twenty videos is enough to see patterns. More videos from the same three creators adds less than a few videos from different ones.

Step 1: find the videos

Best Damn YouTube Scraper can search YouTube and return each video's views and comment count. Sort by view count:

{
    "searchQueries": ["sourdough starter"],
    "searchOrder": "viewCount",
    "maxResults": 15
}

Drop videos with a low commentCount: there is nothing to read. Search is the expensive part of the YouTube API, 100 quota units per search page, so if you run many searches use your own API key (see Cost and limits).

Step 2: collect top comments, without replies

Best Damn YouTube Comments Scraper reads comments through the official YouTube Data API v3. Two settings matter for questions:

  • sortBy: "relevance" returns YouTube's "Top comments" order, so the comments other viewers liked come first. A cap of a few hundred per video keeps the ones that resonated.
  • Leave replies off. Replies count toward the per-video cap. In a test with a 300-comment cap and replies on, one video returned only 20 top-level comments; the other 280 were replies to them. Replies are where people answer each other, not where new questions are asked.
{
    "startUrls": ["https://www.youtube.com/watch?v=VIDEO_ID_1", "https://www.youtube.com/watch?v=VIDEO_ID_2"],
    "sortBy": "relevance",
    "maxComments": 300,
    "authorData": "hash"
}

authorData: "hash" replaces each commenter's channel ID with a stable pseudonym and drops names. You can still count distinct people without knowing who they are.

Step 3: extract, group and rank the questions

A comment counts as a question if a sentence ends in ? or starts with a question word. Short ones ("why?", "what??") are dropped; they react to the video rather than ask about the topic. Plurals are folded crudely, so starters and starter count as one word. Grouping uses the most common topic words across all questions: each question goes to the most frequent word it contains. That is crude, but it needs no extra libraries, and it is easy to see why a question landed where it did.

import re
from collections import Counter, defaultdict
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")

search = client.actor("josh99smith/youtube-scraper").call(run_input={
    "searchQueries": ["sourdough starter"], "searchOrder": "viewCount", "maxResults": 15})
videos = [v["url"] for v in client.dataset(search["defaultDatasetId"]).iterate_items()
          if v["success"] and (v["commentCount"] or 0) >= 50]

run = client.actor("josh99smith/youtube-comments-scraper").call(run_input={
    "startUrls": videos, "sortBy": "relevance", "maxComments": 300, "authorData": "hash"})

QWORD = r"^(how|why|what|which|where|when|can|could|does|do|did|is|are|should|will|would|has|have)(?![\w'’])"
STOP = set("""a an the and or but if so to of in on at for with from by about as is are was were be been
do does did can could should would will has have had i you he she it we they me my your our their this that
these those there here what which who whom whose how why where when not no yes just also than then too very
any some more most much many get got make use using one way still really video thanks thank please
can't don't doesn't isn't into like time know think anyone someone people guys his her him them its""".split())

def questions(text):
    for s in re.split(r"(?<=[.!?])\s+|\n+", text):
        s = s.strip()
        if len(s.split()) >= 4 and (s.endswith("?") or (re.match(QWORD, s, re.I) and not s.endswith((".", "!")))):
            yield s

def words(s):
    ws = set(re.findall(r"[a-z][a-z'’-]{2,}", s.lower())) - STOP
    return {w[:-1] if len(w) > 4 and w.endswith("s") and not w.endswith("ss") else w for w in ws}

found, seen = [], set()
for c in client.dataset(run["defaultDatasetId"]).iterate_items():
    if c["success"] and not c["isByVideoOwner"]:
        for q in questions(c["text"]):
            key = re.sub(r"\W+", " ", q.lower()).strip()
            if key not in seen:  # copy-pasted questions count once
                seen.add(key)
                found.append((q, words(q), c))

freq = Counter(w for _, ws, _ in found for w in ws)
groups = defaultdict(lambda: {"people": set(), "likes": 0, "examples": []})
for q, ws, c in found:
    topic = max(ws, key=lambda w: (freq[w], w)) if ws else "(other)"
    g = groups[topic]
    g["people"].add(c["authorChannelId"])
    g["likes"] += c["likeCount"]
    g["examples"].append((c["likeCount"], q, c["commentUrl"]))

ranked = sorted(groups.items(), key=lambda kv: (-len(kv[1]["people"]), -kv[1]["likes"]))
for topic, g in ranked[:15]:
    print(f"\n{topic}: {len(g['people'])} people, {g['likes']} likes")
    for likes, q, url in sorted(g["examples"], reverse=True)[:3]:
        print(f"  [{likes}] {q[:140]}  {url}")

Add words that appear in every comment for your topic (for example sourdough, starter) to STOP, or every question lands in one group. When the groups get too coarse, embed each question with any sentence-embedding model and cluster the vectors instead; the counting and ranking stay the same.

Read the list before you plan videos

  • Rank by distinct people, then likes. Ten people asking the same thing is a stronger signal than one question with many likes, and likes are how other viewers say "me too" without writing.
  • Read the top examples in each group. Keyword rules cannot tell a sincere question from a joke, and some questions are rhetorical ("who else is here in 2026?"). Those are easy to spot and drop by hand.
  • Check whether a video already answers it. Search your topic plus the question words on YouTube. A question asked under a popular video and still unanswered elsewhere is the best candidate.
  • Note the wording. The way viewers phrase a question is often close to what they type into search, which makes it a good starting point for a title.

Cost and limits

  • Price. Comments cost $0.0004 each ($0.40 per 1,000). Fifteen videos capped at 300 comments is at most 4,500 comments, so at most $1.80. The video search costs $0.001 per video, $0.015 for 15. Unreadable videos, comments-off videos and quota errors are free, and a run stops at the maximum cost you set.
  • Quota and your own key. Both Actors use a built-in API key by default, and its 10,000-unit daily quota is shared by every user. Comments are cheap in quota (one unit per page of up to 100), but each search page costs 100 units. If you search more than a handful of terms, create a free key in the Google Cloud Console and pass it as apiKey to both Actors. You get your own 10,000 units a day, and you don't take quota from other users. When a quota runs out, runs stop cleanly and the remaining inputs come back as free rate-limited records.
  • Top comments are YouTube's ordering. It is not documented and not purely by likes. For a topic where recent questions matter, also run sortBy: "time" with publishedAfter: "3 months".
  • Public data only. No login, nothing members-only.

Comments are personal data under GDPR and similar laws. Work with grouped questions, not people. Keep authorData on hash or omit, and leave names out if you quote a question.

If this saves you time, a review on the Store page helps other people find it, and a star on GitHub helps too.

Disclosure: I built both Actors. Source: github.com/josh99smith/youtube-comments-scraper. YouTube is a trademark of Google; the Actors are not affiliated with Google.

來源:DEV Community · dev.to