From dda985e3992a745468f6385b9bae82b9d2d5ec62 Mon Sep 17 00:00:00 2001 From: Haonan Date: Sat, 2 May 2026 16:18:48 -0600 Subject: [PATCH] fix: migrate from xiaohongshu.com to rednote.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update all navigation URLs to rednote.com - Fix login verification to check for "Me" instead of "我" - Update URL extraction regex to match rednote.com links --- src/auth/authManager.ts | 6 +++--- src/tools/rednoteTools.ts | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/auth/authManager.ts b/src/auth/authManager.ts index ea49618..2075911 100644 --- a/src/auth/authManager.ts +++ b/src/auth/authManager.ts @@ -88,7 +88,7 @@ export class AuthManager { // Navigate to explore page logger.info('Navigating to explore page'); - await this.page.goto('https://www.xiaohongshu.com/explore', { + await this.page.goto('https://www.rednote.com/explore', { waitUntil: 'domcontentloaded', timeout: timeoutMs }); @@ -98,7 +98,7 @@ export class AuthManager { if (userSidebar) { const isLoggedIn = await this.page.evaluate(() => { const sidebarUser = document.querySelector('.user.side-bar-component .channel'); - return sidebarUser?.textContent?.trim() === '我'; + return sidebarUser?.textContent?.trim() === 'Me'; }); if (isLoggedIn) { @@ -131,7 +131,7 @@ export class AuthManager { // Verify the text content const isLoggedIn = await this.page.evaluate(() => { const sidebarUser = document.querySelector('.user.side-bar-component .channel'); - return sidebarUser?.textContent?.trim() === '我'; + return sidebarUser?.textContent?.trim() === 'Me'; }); if (!isLoggedIn) { diff --git a/src/tools/rednoteTools.ts b/src/tools/rednoteTools.ts index 3404bfa..4326572 100644 --- a/src/tools/rednoteTools.ts +++ b/src/tools/rednoteTools.ts @@ -50,10 +50,10 @@ export class RedNoteTools { // Check login status logger.info('Checking login status') - await this.page.goto('https://www.xiaohongshu.com') + await this.page.goto('https://www.rednote.com') const isLoggedIn = await this.page.evaluate(() => { const sidebarUser = document.querySelector('.user.side-bar-component .channel') - return sidebarUser?.textContent?.trim() === '我' + return sidebarUser?.textContent?.trim() === 'Me' }) // If not logged in, perform login @@ -98,12 +98,12 @@ export class RedNoteTools { return xhslinkMatch[1] } - // 匹配 https://www.xiaohongshu.com/ 开头的链接 - const xiaohongshuRegex = /(https?:\/\/(?:www\.)?xiaohongshu\.com\/[^,\s]+)/i - const xiaohongshuMatch = shareText.match(xiaohongshuRegex) + // 匹配 https://www.rednote.com/ 开头的链接 + const rednoteRegex = /(https?:\/\/(?:www\.)?rednote\.com\/[^,\s]+)/i + const rednoteMatch = shareText.match(rednoteRegex) - if (xiaohongshuMatch && xiaohongshuMatch[1]) { - return xiaohongshuMatch[1] + if (rednoteMatch && rednoteMatch[1]) { + return rednoteMatch[1] } return shareText @@ -117,7 +117,7 @@ export class RedNoteTools { // Navigate to search page logger.info('Navigating to search page') - await this.page.goto(`https://www.xiaohongshu.com/search_result?keyword=${encodeURIComponent(keywords)}`) + await this.page.goto(`https://www.rednote.com/search_result?keyword=${encodeURIComponent(keywords)}`) // Wait for search results to load logger.info('Waiting for search results')