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

[QUESTION]fetch_user_profile 请求错误 #298

Open
fxbyun opened this issue Mar 18, 2025 · 1 comment
Open

[QUESTION]fetch_user_profile 请求错误 #298

fxbyun opened this issue Mar 18, 2025 · 1 comment
Labels
重复(duplicate) 与已有的反馈或需求重复(This issue or pull request already exists) 等待反馈(feedback) 需要补充信息或配合测试(Feedbackers are required to add information or cooperate with the test) 无效(invalid) 非代码故障导致错误或异常(Non-code faults causing errors or anomalies) 提问(question) 想得到更多的详细支持(Further information is requested)

Comments

@fxbyun
Copy link

fxbyun commented Mar 18, 2025

问题描述
抖音登录后,打开自己的主页,使用 f2 dy -c conf/app.yaml --auto-cookie chrome 获取到cookie,

Image
执行:f2 dy -c conf/app.yaml 命令后,一直报错:

Image

@fxbyun fxbyun added the 提问(question) 想得到更多的详细支持(Further information is requested) label Mar 18, 2025
Copy link

dosubot bot commented Mar 18, 2025

@fxbyun 你好! 我是Dosu,一个可以帮助你解决 bug、回答问题并成为贡献者的机器人。我会在等待人类维护者的过程中帮助你。

To resolve the "Event loop is closed" error in your Python script using asyncio, you can ensure that the event loop is properly managed and closed. This error typically occurs when the event loop is closed before all asynchronous tasks are completed. Here's a way to handle it:

  1. Use asyncio.run() to manage the event loop, which automatically handles the creation and closing of the event loop.

Here's an example of how you can structure your code using asyncio.run(), incorporating the configuration from your setup:

import asyncio
from f2.apps.douyin.handler import DouyinHandler

async def main():
    kwargs = {
        "headers": {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0",
            "Referer": "https://www.douyin.com/",
        },
        "proxies": {"http://": None, "https://": None},
        "cookie": "YOUR_COOKIE_HERE",
    }
    sec_user_id = "MS4wLjABAAAANXSltcLCzDGmdNFI2Q_QixVTr67NiYzjKOIP5s03CAE"
    user = await DouyinHandler(kwargs).fetch_user_profile(sec_user_id=sec_user_id)
    print("=================_to_raw================")
    print(user._to_raw())
    # print("=================_to_dict===============")
    # print(user._to_dict())

if __name__ == "__main__":
    asyncio.run(main())

Make sure to replace "YOUR_COOKIE_HERE" with the actual cookie obtained using the command f2 dy -c conf/app.yaml --auto-cookie chrome [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@Johnserf-Seed Johnserf-Seed added 重复(duplicate) 与已有的反馈或需求重复(This issue or pull request already exists) 等待反馈(feedback) 需要补充信息或配合测试(Feedbackers are required to add information or cooperate with the test) 无效(invalid) 非代码故障导致错误或异常(Non-code faults causing errors or anomalies) labels Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
重复(duplicate) 与已有的反馈或需求重复(This issue or pull request already exists) 等待反馈(feedback) 需要补充信息或配合测试(Feedbackers are required to add information or cooperate with the test) 无效(invalid) 非代码故障导致错误或异常(Non-code faults causing errors or anomalies) 提问(question) 想得到更多的详细支持(Further information is requested)
Projects
None yet
Development

No branches or pull requests

2 participants