TikTok-Api
TikTok-Api copied to clipboard
[BUG] - raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path)) KeyError: "name='ttwid', domain=None, path=None"
Hi, I have a problem just with a basic exercise taken from the guide
from TikTokApi import TikTokApi
with TikTokApi() as api:
user = api.user(username="therock")
for video in user.videos():
print(video.id)
for liked_video in api.user(username="public_likes").videos():
print(liked_video.id)
Despite reinstalling and installing tiktokAPI, I still get this
Traceback (most recent call last):
File "C:\Users\matti\Desktop\s.py", line 6, in <module>
for video in user.videos(get_all=True):
File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\user.py", line 133, in videos
self.__find_attributes()
File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\user.py", line 263, in __find_attributes
for u in self.parent.search.users(self.username):
File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\search.py", line 85, in search_type
ttwid = spawn.cookies["ttwid"]
File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 328, in __getitem__
return self._find_no_duplicates(name)
File "C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\cookies.py", line 399, in _find_no_duplicates
raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='ttwid', domain=None, path=None"
Do any of you know why this is so?
find this line: ttwid = spawn.cookies["ttwid"] in file C:\Users\matti\AppData\Local\Programs\Python\Python310\lib\site-packages\TikTokApi\api\search.py change it to ttwid = spawn.cookies.get_dict()["ttwid"]
Having the same issue, tried changing how @demon071 said, but not working (ttwid key doesn't exist)
Running from local PC for the first time, no IP block or anything like that
coz the way to get ttwid is updated
@thedevale not working for me too (TikTokApi version 5.2.2)
I was having the exact same issue for long time, I don't know if it could help but in the case of mine was returning 403
(auth problem) while debugging inside trending.py
(could differ based on your request) and was able to workaround by implementing vpn , I know vpn might not be the solution for all issues but I would highly recommend you to check the response inside the file you are calling eg in search.py
spawn = requests.head(
"https://www.tiktok.com",
proxies=Search.parent._format_proxy(processed.proxy),
**Search.parent._requests_extra_kwargs
)
print(spawn)
I see your comment, I tried to look at the output of this spawn and it seems like I am getting 403 error too
I tried a vpn no good
does anyone find a solution for that, im haing the same problem
should be fixed v6