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] 如何不使用配置文件来配置代理? #201

Open
Cyhlnj opened this issue Nov 17, 2024 · 2 comments
Open

[QUESTION] 如何不使用配置文件来配置代理? #201

Cyhlnj opened this issue Nov 17, 2024 · 2 comments
Labels
已确认(confirmed) 该issue已被处理,将在下次推送中更新(The issue has been processed and will be updated in the next push) 提问(question) 想得到更多的详细支持(Further information is requested)

Comments

@Cyhlnj
Copy link

Cyhlnj commented Nov 17, 2024

proxy = "socks5://192.168.9.117:1081"
kwargs = {
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
        "Referer"   : "https://www.tiktok.com/",
    },
    "cookie" : "YOUR_COOKIE_HERE",
    # "proxies": {"http://": None, "https://": None},
    "proxies": {"http://": proxy, "https://": proxy},
}

async def main():
    secUid = (
        "MS4wLjABAAAAQhcYf_TjRKUku-aF8oqngAfzrYksgGLRz8CKMciBFdfR54HQu3qGs-WoJ-KO7hO8"
    )
    user = await TiktokHandler(kwargs).fetch_user_profile(secUid=secUid)
    print("=================_to_raw================")
    print(user._to_raw())

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

问题描述
我在kwargs里面设置了代理,但是函数运行的时候似乎在gen_real_msToken()时并没有使用kwargs里面的代理,而是使用了配置文件里面的代理。
File "/Users/cyh/.virtualenvs/feeyo/lib/python3.9/site-packages/f2/apps/tiktok/utils.py", line 1081, in DeviceIdManager "Cookie": f"msToken={TokenManager.gen_real_msToken()}", File "/Users/cyh/.virtualenvs/feeyo/lib/python3.9/site-packages/f2/apps/tiktok/utils.py", line 176, in gen_real_msToken raise APITimeoutError( f2.exceptions.api_exceptions.APITimeoutError: 请求端点超时。链接:https://mssdk-sg.tiktok.com/web/common?msToken=QnC7zMMh1cpaDTxHDHnabNOrqaWv49JwA1IAq3AIFvrdaqQi8Rs_YlXSya1vN-4b6C1MgpWpS2cL1oakaUEDe3pUDMLpCbdSc3b3V98Fux0AuwXn_9Ns3FyMTnFRmSOOOVeGg6bVXMSGoMG6dq3k,代理:{'http://': None, 'https://': None},异常类名:TokenManager,异常详细信息:timed out

期望的支持
能否让我只在一个地方设置代理就可以获取到数据?

@Cyhlnj Cyhlnj added the 提问(question) 想得到更多的详细支持(Further information is requested) label Nov 17, 2024
@Johnserf-Seed
Copy link
Owner

Johnserf-Seed commented Nov 21, 2024

这一点已在0.0.1.7版本中修复

@Cyhlnj
Copy link
Author

Cyhlnj commented Nov 21, 2024

非常感谢!我自己已经修改了,我尝试了在配置文件中配置socks5代理,但是似乎目前的请求类并不能成功使用socks5代理,只有代理设置为空 并且clash打开的情况下 可以采集到;我自己把生成msToken 和 请求endpoint的两个接口 用requests加socks5代理 是可以成功访问到数据的。。

@Johnserf-Seed Johnserf-Seed added the 已确认(confirmed) 该issue已被处理,将在下次推送中更新(The issue has been processed and will be updated in the next push) label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
已确认(confirmed) 该issue已被处理,将在下次推送中更新(The issue has been processed and will be updated in the next push) 提问(question) 想得到更多的详细支持(Further information is requested)
Projects
None yet
Development

No branches or pull requests

2 participants