Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the pypi index version of browser_cookie3 in requirements.txt #627

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

songzy12
Copy link
Collaborator

@songzy12 songzy12 commented Jan 2, 2025

并且修复以下问题:

这里的 cookie 有可能不含 "MLOGIN" 这个 key,例如此时我未登录的 cookie 为:

{'SUB': '_2A25I0S7kDeRhGeVP6lET9yjJzjmIHXVrry4srDV6PUJbktANLWXAkW1NTU8PBZ0pWcKBCiA1prnv4RhE1j-P_CWd', 'SUBP': '0033WrSXqPxfM725Ws9jqgMF55529P9D9WhxVcpPFHOwH1VA0_OSa3CL5JpX5KzhUgL.FoepeKeES0qfSK-2dJLoI7R_TPW0IPxQUPiDMcX_TBtt'}

在这种情况下会抛异常:

Check for cookie failed: 'MLOGIN'
'MLOGIN'
Traceback (most recent call last):
  File "/Users/songzy/weiboSpider/weibo_spider/spider.py", line 387, in main
    config = _get_config()
  File "/Users/songzy/weiboSpider/weibo_spider/spider.py", line 376, in _get_config
    config_util.check_cookie(config_path)
  File "/Users/songzy/weiboSpider/weibo_spider/config_util.py", line 211, in check_cookie
    if cookie["MLOGIN"] == '0':
KeyError: 'MLOGIN'

可修正为

        if cookie.get("MLOGIN", '0') == '0':

@dataabc dataabc merged commit 282176b into dataabc:master Jan 2, 2025
1 check failed
@dataabc
Copy link
Owner

dataabc commented Jan 2, 2025

已merge,好久不见,感谢修复代码。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants