davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.76k stars 960 forks source link

[QUESTION] - How to use proxies to get anothor region TikToks? #1146

Open AbubakrChan opened 5 months ago

AbubakrChan commented 5 months ago

Right now, I am able to fetch trending videos in my region only. I would like to be able to fetch anoyother region (like Japan) TikToks.

I was suggested to use proxies so I tried enabling VPN and it resulted into errors. If anyone can guide me on how I can successully set a proxy that would be great.

I also asked my colleagues from US to give me there mstoken so I can access TikTok from that region but that also didn't worked out.

I would be very thankfull for any kind of help.

Thanks

Gereks123 commented 4 months ago

When creating a session, have you tired passing a list of proxies? https://github.com/davidteather/TikTok-Api/blob/main/TikTokApi/tiktok.py#L203

AbubakrChan commented 4 months ago

@Gereks123 - Thank you for your reply! Yes I tried passing the list of proxies and it gave me "playwright timeout 30000ms exceeded" error. Please share if you have a working solution for this. Thanks.

AbubakrChan commented 4 months ago

Or if you can share a sample code for the correct way to pass the proxy list, that would be great. Thanks

AbubakrChan commented 4 months ago

here is how I am passing the proxy:

await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, context_options=context_options, proxies=['50.217.226.44:80'])
hitsuzi-meme commented 3 months ago

@AbubakrChan Hello, How about the following code?

await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, context_options=context_options, proxies=[{"server": "http://50.217.226.44:80"}])