Extracting Reply Count from Yahoo News Comments
Yahoo News comments show reply counts in a button with text like "返信3件".
Button Text Pattern
返信3件
返信10件
Pattern: 返信(\d+)件
Extraction Method
let replyCount = 0;
const replyButton = item.querySelector('button.sc-169yn8p-12');
if (replyButton) {
const replyText = replyButton.textContent?.trim() || '';
const replyMatch = replyText.match(/返信(\d+)件/);
if (replyMatch) {
replyCount = parseInt(replyMatch[1], 10);
}
}
Output Structure
Only include reply count if > 0:
{
text: "Comment text here",
username: "user123",
replyCount: 3 // Only included if > 0
}
Code Example
const comment = {
text: commentText,
username: username || undefined,
reactions: reactions || undefined,
replyCount: replyCount > 0 ? replyCount : undefined,
};
Notes
- Selector:
button.sc-169yn8p-12 - Japanese: "返信" = reply, "件" = counter suffix
- Only include in output if count > 0
- Nested replies themselves require clicking the button (not implemented)