[BUG] - KeyError
See original GitHub issueCode:
from TikTokApi import TikTokApi
api = TikTokApi()
for video in api.trending.videos():
print(video.as_dict)
Error:
Traceback (most recent call last):
File "d:\TikTok\TikTok ID Samples.py", line 3, in <module>
for video in api.trending.videos():
File "C:\Users\fun64\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\trending.py", line 40, in videos
ttwid = spawn.cookies["ttwid"]
File "C:\Users\fun64\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 334, in __getitem__
return self._find_no_duplicates(name)
File "C:\Users\fun64\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 413, in _find_no_duplicates
raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}")
KeyError: "name='ttwid', domain=None, path=None"
Issue Analytics
- State:
- Created a year ago
- Reactions:13
- Comments:22
Top Results From Across the Web
Python KeyError Exceptions and How to Handle Them
A Python KeyError exception is what is raised when you try to access a key that isn't in a dictionary ( dict )....
Read more >keyerror in Python – How to Fix Dictionary Error
When working with dictionaries in Python, a KeyError gets raised when you try to access an item that doesn't exist in a Python...
Read more >[BUG] KeyError: 'unix_user' with setuptools 63.2.0 #3582
It seems to me like installing a development version becomes increasingly impossible. Expected behavior. The error should not happen. How to ...
Read more >I'm getting Key error in python - Stack Overflow
A KeyError generally means the key doesn't exist. So, are you sure the path key exists? From the official python docs: exception KeyError....
Read more >Is this a bug? KeyError: 'is_popup' on mysite/admin, while ...
Is this a bug? KeyError: 'is_popup' on mysite/admin, while logging level = DEBUG. Django 1.10.6. 1167 views.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey everyone! I managed to get a fix (hopefully it works to others). I changed
C:\Users\user\AppData\Local\Programs\Python\Python310\Lib\site-packages\TikTokApi\api\search.py
for this.You change…
to…
Basically, I changed the request type from HEAD to GET, and added a User-Agent. I compiled all the answers I found from trying to fix this error, so technically this piece of work was a team effort.
Quick notice: Some other python files still have that old code. So just replace that old code with the new one. If it still errors, try to get some common sense and maybe you can fix it.
I think I can solve this problem by logging into tiktok and importing the cookie https://github.com/davidteather/TikTok-Api/issues/891#issuecomment-1148930488