feat(x): Nitter 프로필 조회 함수 추가

- fetchProfile() 함수 추가: username으로 프로필 정보 조회
- displayName, avatarUrl 반환

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
caadiq 2026-02-07 20:08:59 +09:00
parent 4f11e14b12
commit 535fbb6768

View file

@ -218,6 +218,32 @@ export async function fetchSingleTweet(nitterUrl, username, postId) {
};
}
/**
* Nitter에서 프로필 정보만 조회
*/
export async function fetchProfile(nitterUrl, username) {
const url = `${nitterUrl}/${username}`;
const res = await fetchWithTimeout(url);
const html = await res.text();
// 프로필이 존재하는지 확인
if (html.includes('Error: User') || html.includes('User not found')) {
throw new Error('사용자를 찾을 수 없습니다');
}
const profile = extractProfile(html);
if (!profile.displayName) {
throw new Error('프로필 정보를 가져올 수 없습니다');
}
return {
username,
displayName: profile.displayName,
avatarUrl: profile.avatarUrl,
};
}
/**
* Nitter에서 트윗 수집 ( 페이지만)
*/