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

user.portrait 出现 ?t= url参数 #78

Closed
single-ptilopsis opened this issue Jan 11, 2023 · 4 comments
Closed

user.portrait 出现 ?t= url参数 #78

single-ptilopsis opened this issue Jan 11, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@single-ptilopsis
Copy link

简要描述这个bug

贴吧接口真是太神奇啦

如何复现

import asyncio

import aiotieba as tb


async def run():
    async with tb.Client() as client:
        posts = await client.get_posts(8176989942, pn=7)
        for post in posts:
            if post.floor == 197:
                # tb.1.f786.6nEjx1tEYgNNTxjZeaefFg?t=1673398976
                print(post.user.portrait)

loop = asyncio.get_event_loop()
loop.run_until_complete(run())

你希望程序作出何种行为

对portrait做处理,清除 ?t=

@lumina37
Copy link
Owner

aiotieba==2.10.2
cpython==3.11.1
的运行结果

...temp.py:14: DeprecationWarning: There is no current event loop
  loop = asyncio.get_event_loop()
tb.1.f786.6nEjx1tEYgNNTxjZeaefFg

@lumina37 lumina37 added the bug Something isn't working label Jan 11, 2023
@single-ptilopsis
Copy link
Author

结论: beg_start 长了
aiotieba/client/common/typedef/common.py

    @portrait.setter
    def portrait(self, new_portrait: str) -> None:

        if new_portrait and self.is_portrait(new_portrait):

            # beg_start = 33 
           beg_start = 32
            q_index = new_portrait.find('?', beg_start)
            and_index = new_portrait.find('&', beg_start)

            if q_index != -1:
                self._portrait = new_portrait[:q_index]
            elif and_index != -1:
                self._portrait = new_portrait[:and_index]
            else:
                self._portrait = new_portrait

        else:
            self._portrait = ''

不过v2.10.2换了种处理方式,没beg_start什么事了

@n0099
Copy link

n0099 commented Jan 11, 2023

那个?t= url querystring实际上是该用户最后一次更换头像的时间,详见:#64 (comment)

@n0099
Copy link

n0099 commented Jan 13, 2023

fixed in https://github.com/Starry-OvO/aiotieba/releases/tag/v2.10.3

适配因为长期未更换头像而不包含query_string的portrait值

比如我 https://tieba.baidu.com/home/main?id=tb.1.c3bc6401.cuFllz86fDotNQKqB4WJ2Q 从13年至今从未更换过头像
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants