Comments (13)
I've tried this any it work: in the
api.create_sessions
you should add the paramheadless=False
, this will open the playwright browser on your computer and then you can have the response. Full command:api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, headless=False)
It's a bit annoying but preventing the Empty Response error
This can also be fixed by setting the user_agent
and viewport
in the context_options
while remaining headless
import asyncio
import os
ms_token = os.environ.get(
"ms_token", None
)
context_options = {
'viewport' : { 'width': 1280, 'height': 1024 },
'user_agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36'
}
async def trending_videos():
async with TikTokApi() as api:
await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, context_options=context_options)
async for video in api.trending.videos(count=30):
print(video)
print(video.as_dict)
if __name__ == "__main__":
asyncio.run(trending_videos())
This also seems to bypass the need to have a ms_token
from tiktok-api.
I've tried this any it work: in the api.create_sessions
you should add the param headless=False
, this will open the playwright browser on your computer and then you can have the response. Full command:
api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, headless=False)
It's a bit annoying but preventing the Empty Response error
from tiktok-api.
Looks like api is broken, i tried manualy do request to get user info https://www.tiktok.com/api/user/detail/?uniqueId=therock&msToken=token and its really return empty response
from tiktok-api.
I am getting this same exception on Mac Vetura 13.3 with the basic "trending videos" example.
`from TikTokApi import TikTokApi
import asyncio
import os
ms_token = os.environ.get("ms_token", None) # get your own ms_token from your cookies on tiktok.com
async def trending_videos():
async with TikTokApi() as api:
await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3)
async for video in api.trending.videos(count=30):
print(video)
print(video.as_dict)
if name == "main":
asyncio.run(trending_videos())`
Traceback:
/Users/alexsharper/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020 warnings.warn( Traceback (most recent call last): File "/Users/alexsharper/Documents/Lancing/Etai/TikTokBot/ex1.py", line 15, in <module> asyncio.run(trending_videos()) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/Users/alexsharper/Documents/Lancing/Etai/TikTokBot/ex1.py", line 10, in trending_videos async for video in api.trending.videos(count=30): File "/Users/alexsharper/Library/Python/3.9/lib/python/site-packages/TikTokApi/api/trending.py", line 43, in videos resp = await Trending.parent.make_request( File "/Users/alexsharper/Library/Python/3.9/lib/python/site-packages/TikTokApi/tiktok.py", line 430, in make_request raise EmptyResponseException(result, "TikTok returned an empty response") TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response
from tiktok-api.
Any updates on this? Running the basic example and I was able to get a response once but after that I get "TikTok returned an empty response"
from tiktok-api.
I have the same issue...
from tiktok-api.
Nope, for comments still doesn't work
from tiktok-api.
@VitoLin This worked for me for a few runs, then it went back to the "EmptyResponseException: None -> TikTok returned an empty response" error. Any idea why it only works periodically? Is there a rate limit or something? Thanks
from tiktok-api.
Has anyone tried rotating the ms_token or proxy we go through? It might be bot/scraping-detection on TikTok's part.
from tiktok-api.
Has anyone tried rotating the ms_token or proxy we go through? It might be bot/scraping-detection on TikTok's part.
What do you mean by "rotating" the ms_token? And how would one do that? Thanks! @jpratt9
from tiktok-api.
I've tried this any it work: in the
api.create_sessions
you should add the paramheadless=False
, this will open the playwright browser on your computer and then you can have the response. Full command:api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, headless=False)
It's a bit annoying but preventing the Empty Response error
This can also be fixed by setting the
user_agent
andviewport
in thecontext_options
while remaining headlessimport asyncio import os ms_token = os.environ.get( "ms_token", None ) context_options = { 'viewport' : { 'width': 1280, 'height': 1024 }, 'user_agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36' } async def trending_videos(): async with TikTokApi() as api: await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, context_options=context_options) async for video in api.trending.videos(count=30): print(video) print(video.as_dict) if __name__ == "__main__": asyncio.run(trending_videos())
This also seems to bypass the need to have a ms_token
This only seems to work for me with api.trending, not api.user
from tiktok-api.
I'm still getting EmptyResponse no matter which one I try, even with headless=False
from tiktok-api.
Finally, I got a response. Maybe someone can help me out with headless=False
. How not to show the pop-up window?
Without this attribute, I got error: TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response
from tiktok-api.
Related Issues (20)
- Proxy not working
- [BUG] - Error extract information of videos from user
- [FEATURE_REQUEST] - How to Scrap Collections- User Collections HOT 1
- [INSTALLATION] - TypeError: 'type' object is not subscriptable HOT 3
- [BUG] - Error encountered getting user videos: TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response HOT 5
- [BUG] - Seems like Pagination is broken? HOT 1
- [INSTALLATION] - Question about Obtaining and Configuring ms_token in the Project HOT 13
- Ha
- [INSTALLATION] - ModuleNotFoundError: No module named 'TikTokApi' HOT 3
- What does error_code 1031 mean?
- Just Want Text
- cause of "EmptyResponseException: None -> TikTok returned an empty response" error HOT 4
- [FEATURE_REQUEST] - Multiple hashtags for api
- Getting more video ids than 30 fails HOT 10
- I got error " Failed to get msToken from cookies" HOT 2
- [BUG] - Empty userInfo for small accounts HOT 1
- Videos generated in the last 24 hours for a specific word
- Any function returns permanently empty fields HOT 7
- Is this repo available now?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tiktok-api.