탐색으로 건너뛰기

How can Python turn Douyin storage research into a sourced question list?

To turn Douyin research into a sourced question list with Python, fetch one page of Douyin search results with douyin.search.fetch_general_search_v2, select the videos that show the use case, then fetch top-level comments for each selected video’s aweme_id with douyin.app.v3.fetch_video_comments. With a verified video ID, start at the comments. Put the question, exact quote, situation and source on the same row.

For example, for renter storage research, search for “renter storage,” select videos that show how people use the product, and look for questions about dimensions, access and disassembly. Read the original comments before choosing a tutorial topic.

1. Define one research round

Use the Python 3 standard library, and set BEATAPI_API_KEY in your local environment. One search page plus the first comment batch of three selected videos is a plan of at most four queries; the actual candidate and comment counts depend on the results. See current pricing.

The example searches videos from the past week with comprehensive sorting. For newer publications, change sort_type to the string "2"; to discover the most-liked candidates, use "1". Sorting helps discovery; relevance comes from inspecting each work.

2. Save one request and its original response

Save the script below as dy_read.py. Each run requests one search batch or one comment batch, and saves the conditions, the time and the response in a new directory.

import json
import os
import sys
from datetime import datetime, timezone
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
if len(sys.argv) != 4 or sys.argv[1] not in {"search", "comments"}:
raise SystemExit("Usage: python3 dy_read.py search|comments VALUE NEW_DIRECTORY")
mode, value, directory = sys.argv[1:]
if not value.strip():
raise SystemExit("Supply a keyword or a verified aweme ID")
key = os.environ.get("BEATAPI_API_KEY")
if not key:
raise SystemExit("Set BEATAPI_API_KEY in your local environment")
if mode == "search":
action = "douyin.search.fetch_general_search_v2"
params = {"keyword": value, "cursor": 0, "sort_type": "0",
"publish_time": "7", "filter_duration": "0", "content_type": "1",
"search_id": "", "backtrace": ""}
else:
action = "douyin.app.v3.fetch_video_comments"
params = {"aweme_id": value, "cursor": 0}
body = {"action": action, "params": params}
out = Path(directory)
out.mkdir(parents=True, exist_ok=False)
(out / "request.json").write_text(json.dumps(body, ensure_ascii=False, indent=2), encoding="utf-8")
started = datetime.now(timezone.utc).isoformat()
(out / "attempt.json").write_text(json.dumps({"started_at": started, "action": action}), encoding="utf-8")
request = Request("https://api.beatapi.io/v1/social-data/call",
data=json.dumps(body).encode("utf-8"), method="POST",
headers={"Authorization": "Bearer " + key, "Content-Type": "application/json"})
try:
with urlopen(request, timeout=60) as response:
status, raw = response.status, response.read()
except HTTPError as error:
status, raw = error.code, error.read()
except URLError:
(out / "transport-error.json").write_text(json.dumps({"outcome": "unknown", "action": action}), encoding="utf-8")
raise SystemExit("No final response saved; review the attempted request before repeating")
(out / "response.json").write_bytes(raw)
(out / "call.json").write_text(json.dumps({"action": action, "params": params,
"http_status": status, "started_at": started,
"finished_at": datetime.now(timezone.utc).isoformat(),
"response_file": "response.json", "platform_review": "required"},
ensure_ascii=False, indent=2), encoding="utf-8")
try:
payload = json.loads(raw)
except (ValueError, UnicodeError):
raise SystemExit("Saved a non-JSON response; inspect response.json")
if status != 200 or not isinstance(payload, dict) or payload.get("status") != "succeeded" or payload.get("error") is not None or payload.get("action") != action:
raise SystemExit("Saved a failed or unexpected response; inspect response.json")
print("Saved response for platform-content review: " + str(out / "response.json"))

Start with search:

python3 dy_read.py search '租房收纳' dy-search-01

The search uses douyin.search.fetch_general_search_v2. publish_time:"7" means the past week, content_type:"1" selects videos, and filter_duration:"0" leaves duration unrestricted. For another scope, change the matching condition explicitly and save the query in a separate directory.

dy_read.py checks the gateway execution state and keeps the platform material. Review the actual works in response.json; call.json records the batch’s conditions and retrieval time. An HTTP error keeps the original error response, and a missing final response leaves an attempt record for review.

3. Select relevant works from the first batch

Check that each work concerns rental storage, then select works with distinct use cases: measuring a shallow cabinet, reaching frequently used items or dismantling storage during a move. Record each work’s source, actual work identifier and selection reason.

Likes can point to an interesting candidate, but the search page is still only a sample. Exclude unrelated home décor, and judge relevance from each work itself.

Confirm the aweme_id from the actual work before requesting comments. aweme_id identifies the work, a different object from the author’s uid or sec_uid. With only a link, follow work links and IDs.

4. Read the selected work’s first comment batch

python3 dy_read.py comments '<confirmed_aweme_id>' dy-comments-01

The comment action is douyin.app.v3.fetch_video_comments, starting at cursor:0 with the default count. For another video, use the other video’s work ID and a new output directory, so every comment batch stays linked to the work the batch came from.

Before organizing the comments, check whether the comments concern the same cabinet or solution:

Sample comment patternContent questionNext step
“My cabinet is only 30 cm deep”Dimensions required by the solutionReview the work, measurement method and unresolved size
“Taking it out every day is awkward”Access frequency and layoutLook for the item, position and usage process
“Can it come apart when I move?”Dismantling and reuseRead author replies, separating questions from experience
“Link?” or “same question”Interest or a response to an earlier commentPreserve original words with the parent context

The table illustrates how to classify viewer comments into research questions. For an author explanation, continue with the comment/reply workflow. Replies need the work’s item_id and the selected comment’s comment_id, each confirmed separately.

5. Continue when more material is useful

dy_read.py reads first batches only. Search continuation keeps the same filters and sends the cursor, search_id and backtrace from the actual response. Comment continuation sends the previous cursor of the same work. Keep the search and comment continuation histories separate, and continue only within the planned work and page scope.

Because douyin.search.fetch_general_search_v2 and douyin.app.v3.fetch_video_comments return raw platform payloads without fixed top-level text paths, save the original responses and build a manual question table after inspecting the returned structure rather than parsing into fixed-column CSVs. Saved material can be revisited without another platform query.

6. Hand off useful content questions

Group the actual themes, such as dimensions, access and dismantling. For each theme, include the original words, work and comment sources, conditions, author answers, open questions and possible content. Merge repeated objects by actual identifier, and report the comment count separately from the number of distinct works.

For example, “How do I measure cabinet depth?” can become a measuring tutorial. A vague complaint without an object or conditions stays open. The hand-off should show a colleague what to explain next and where the evidence is.

To hand the material to an assistant:

Reuse this rental-storage search and comment material. Organize specific questions about dimensions, access and dismantling with original words, sources and known conditions. Preserve author explanations, suggest content topics and identify material still needed, stating the actual scope.

Find high-engagement examples from smaller creators

Start with douyin.billboard.fetch_hot_total_low_fan_list, for example with {"page":1,"page_size":10,"date_window":24,"keyword":"租房收纳"}. date_window is in hours and accepts 1, 24, 72 and 168. Page through the leaderboard with the action’s own page number, and take counts and fields from the actual response. Keep the leaderboard sample separate from the regular search sample.

If your team defines a follower ceiling, verify the actual follower counts of the search sample above, and record the threshold and observation time. Compare engagement and plays separately, and mark missing counts. Read the selected videos and comments for a technique worth trying, such as showing cabinet dimensions before demonstrating storage. For each example, deliver the source, the selection reason and the technique.