NanmiCoder/MediaCrawler · error
[XiaoHongShuLogin.begin]I nvalid Login Type Currently only s
Error message
[XiaoHongShuLogin.begin]I nvalid Login Type Currently only supported qrcode or phone or cookies ...
What it means
ValueError raised by XiaoHongShuLogin.begin when config.LOGIN_TYPE is not 'qrcode', 'phone', or 'cookies' (note: xhs uses 'cookies' with an s, unlike weibo/zhihu). Thrown before login starts; purely a config-validation failure.
Source
Thrown at media_platform/xhs/login.py:97
# If web_session has changed, consider the login successful
if current_web_session and current_web_session != no_logged_in_session:
utils.logger.info("[XiaoHongShuLogin.check_login_state] Login status confirmed by Cookie (web_session changed).")
return True
return False
async def begin(self):
"""Start login xiaohongshu"""
utils.logger.info("[XiaoHongShuLogin.begin] Begin login xiaohongshu ...")
if config.LOGIN_TYPE == "qrcode":
await self.login_by_qrcode()
elif config.LOGIN_TYPE == "phone":
await self.login_by_mobile()
elif config.LOGIN_TYPE == "cookie":
await self.login_by_cookies()
else:
raise ValueError("[XiaoHongShuLogin.begin]I nvalid Login Type Currently only supported qrcode or phone or cookies ...")
async def login_by_mobile(self):
"""Login xiaohongshu by mobile"""
utils.logger.info("[XiaoHongShuLogin.login_by_mobile] Begin login xiaohongshu by mobile ...")
await asyncio.sleep(1)
try:
# After entering Xiaohongshu homepage, the login dialog may not pop up automatically, need to manually click login button
login_button_ele = await self.context_page.wait_for_selector(
selector="xpath=//*[@id='app']/div[1]/div[2]/div[1]/ul/div[1]/button",
timeout=5000
)
await login_button_ele.click()
# The login dialog has two forms: one shows phone number and verification code directly
# The other requires clicking to switch to phone login
element = await self.context_page.wait_for_selector(
selector='xpath=//div[@class="login-container"]//div[@class="other-method"]/div[1]',
timeout=5000
)View on GitHub (pinned to d6f7c5bb90)
Solutions
- Set LOGIN_TYPE to exactly 'qrcode', 'phone', or 'cookies' in the xhs config.
- Double-check the plural 'cookies' spelling - the most common trap coming from weibo/zhihu configs.
- Check the value passed with --lt on the command line.
Example fix
# before LOGIN_TYPE = "cookie" # works for weibo, fails for xhs # after LOGIN_TYPE = "cookies"
Defensive patterns
Strategy: validation
Validate before calling
import config
assert config.LOGIN_TYPE in {"qrcode", "phone", "cookies"}, f"bad LOGIN_TYPE: {config.LOGIN_TYPE!r}" Type guard
def is_valid_xhs_login_type(value: str) -> bool:
return isinstance(value, str) and value in {"qrcode", "phone", "cookies"} Prevention
- Remember xhs accepts 'cookies' (plural), unlike weibo's 'cookie'.
- Validate LOGIN_TYPE once at startup against a per-platform allowlist.
- Avoid hand-editing config late at night - this error is almost always a typo.
When it happens
Trigger: LOGIN_TYPE misspelled or set to an unsupported value (e.g. 'cookie' for xhs where the accepted literal is 'cookies', 'scan', 'sms'), or config copied from the weibo section.
Common situations: Cross-platform config reuse where the user assumes 'cookie' works everywhere; typo in --lt CLI argument; trailing whitespace or wrong case.
Related errors
- [WeiboLogin.begin] Invalid Login Type Currently only support
- Unable to parse creator info from URL: {url}
- [ZhiHu.begin]I nvalid Login Type Currently only supported qr
- [KuaishouLogin.begin] Invalid Login Type Currently only supp
- [BaiduTieBaLogin.begin]Invalid Login Type Currently only sup
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/d4d27fee109cf36c.
Report an issue: GitHub.