[BUG] - KeyError: "name='ttwid', domain=None, path=None"
So I was trying to get user videos and I try to follow the example code :
from TikTokApi import TikTokApi
verify_fp = "verify_xxx"
# Notes : im using my own verify_fp
api = TikTokApi(custom_verify_fp=verify_fp)
user = api.user(username="therock")
for video in user.videos():
print(video.id)
Expected behavior
List of user videos based on username I wrote.
Error Trace (if any)
Traceback (most recent call last):
File "/home/rachmadrin/api-social-media/testing_tiktok.py", line 10, in <module>
for video in user.videos():
File "/home/rachmadrin/venv-kolabora/lib/python3.8/site-packages/TikTokApi/api/user.py", line 133, in videos
self.__find_attributes()
File "/home/rachmadrin/venv-kolabora/lib/python3.8/site-packages/TikTokApi/api/user.py", line 263, in __find_attributes
for u in self.parent.search.users(self.username):
File "/home/rachmadrin/venv-kolabora/lib/python3.8/site-packages/TikTokApi/api/search.py", line 85, in search_type
ttwid = spawn.cookies["ttwid"]
File "/home/rachmadrin/venv-kolabora/lib/python3.8/site-packages/requests/cookies.py", line 328, in __getitem__
return self._find_no_duplicates(name)
File "/home/rachmadrin/venv-kolabora/lib/python3.8/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"
Notes : it's still do the same error even if I didn't use custom_verify_fp anymore
Environment:
- OS: Ubuntu 20.04
- TikTokApi Version 5.0.0
I get this too
I get this too
I get this too
I get this too, docker run
I get this too
这个问题解决了么
这个问题解决了么
until today these issues still happen, dude.
直到今天,这个问题仍然发生,伙计。
@mengguiyouziyi
Same here. Going back to 4.1.0 for now.
Same here. Going back to 4.1.0 for now.
do the older versions work?
i get the above terminal prompt too
I get this too
I too, version 5.1.1
Same, version 5.1.1
Same here. Going back to 4.1.0 for now.
The same error appears in v4.1.0 as well for me
I get this too.
Windows 11 version 5.1.1
Hi, I have the same problem with both 4.1.0 and 5.1.1. I haven't installed "chromedriver globally" because i'm not the machine administrator, but in this machine i use python scripts with selenium and ChromeDriverManager without issues:
# Initialize a new browser
def start_chrome_driver(url, wait=30):
"""
create an instance of selenium Chrome
:param url: the url of the site to connect to
:type url: string
:param wait: seconds to wait
:type wait: int
:return: driver
:rtype: webdriver.Chrome
"""
user_data_dir = f"{os.getcwd()}\\UserData"
os.makedirs(os.path.dirname(user_data_dir), exist_ok=True)
sys.path.append(user_data_dir)
options = Options()
options.headless = True
options.add_argument("--window-position=10,10")
options.add_argument('--user-agent=Chrome/79.0.3945.130 Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
'AppleWebKit/537.36 (KHTML, like Gecko) ')
options.add_argument("--no-sandbox")
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
options.add_argument("--disable-d3d11")
options.add_argument("--disable-dev-shm-usage")
options.add_argument(f'user-data-dir={user_data_dir}')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.implicitly_wait(wait)
driver.get(url)
return driver
+1, not working
Same here
Same here
This suggestion solves the ttwid error but then there's a CaptchaException: https://github.com/davidteather/TikTok-Api/issues/890#issuecomment-1145724326
+1
same issue here
+1
Is anyone got any solution ?
Same here
same problem here
Same for me. It seems that there is anti-bot mechanism which adds _abck and bm_sz cookies at the beginning. (https://security.stackexchange.com/questions/182895/anti-bot-javascript-library-identification). TikTok-Api uses requests lib to call http://www.tiktok.com to get ttwid cookie but anti-bot tool detects that it's not a human and returns 403 code without attaching ttwid. You can check it by returning status code just before this line: https://github.com/davidteather/TikTok-Api/blob/master/TikTokApi/api/search.py#L85
I suppose real request from the browser (e.g. via selenium) for the first call would resolve the issue. I'm able to retrieve ttwid with Postman's call.
+1
+1
So It doesn't work ?