[BUG] - Your Error Here
See original GitHub issueRead Below!!! If this doesn’t fix your issue delete these two lines
You may need to install chromedriver for your machine globally. Download it here and add it to your path.
Describe the bug Getting an error in call get_trending function
A clear and concise description of what the bug is. Tried to execute get_trending.py in the example folder by getting an error. I also tried to input a custom_verifyfp but still getting the same error.
The buggy code
get_trending.py
Please insert the code that is throwing errors or is giving you weird unexpected results.
- script I tried to execute is get_trending.py.
- second script is below, which uses the customverifyFp.
from TikTokApi import TikTokApi api = TikTokApi.get_instance() results = 10
trending = api.by_trending(count=results, custom_verifyFp=“verify_kyat3dlk_jjAEDYEw_aHce_4kZD_9uu3_J9WvCO7ktDtA”)
for tiktok in trending: # Prints the id of the tiktok print(tiktok[‘id’])
print(len(trending))
# Code Goes Here
Expected behavior Able to pull the list of trending videos
A clear and concise description of what you expected to happen. Able to pull the list of trending videos
Error Trace (if any)
Put the error trace below if there’s any error thrown.
# Error Trace Here
File “C:\Projects\tiktok\test.py”, line 7, in <module> trending = api.by_trending(count=results, custom_verifyFp=“verify_kyat3dlk_jjAEDYEw_aHce_4kZD_9uu3_J9WvCO7ktDtA”) File “C:\Projects\tiktok\env\lib\site-packages\TikTokApi\tiktok.py”, line 486, in by_trending ttwid = spawn.cookies[“ttwid”] File “C:\Projects\tiktok\env\lib\site-packages\requests\cookies.py”, line 328, in getitem return self._find_no_duplicates(name) File “C:\Projects\tiktok\env\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”
Desktop (please complete the following information):
- OS: Windows 10
- TikTokApi Version : 4.1.0
Additional context
Add any other context about the problem here. Haven’t download chromedriver, is it really required?
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (1 by maintainers)
Top GitHub Comments
Please try using V5.0.0 this may solve your problem
Looks like tiktok doesn’t generate
ttwid
cookie via HEAD request anymore. https://github.com/davidteather/TikTok-Api/blob/a356324ab3171d473619fdf3e1dd71e5996cfc29/TikTokApi/tiktok.py#L481Replace
request.head
torequest.get
at 481 line oftiktok.py
https://github.com/davidteather/TikTok-Api/blob/a356324ab3171d473619fdf3e1dd71e5996cfc29/TikTokApi/tiktok.py#L481OR
You can change line 486 in
tiktok.py
. You will need to replacettwid = spawn.cookies["ttwid"]
forttwid = YOURCOOKIE
where isYOURCOOKIE
is yourttwid
cookie which you can get by navigating to tiktok.com from your browser (or via GET request). https://github.com/davidteather/TikTok-Api/blob/a356324ab3171d473619fdf3e1dd71e5996cfc29/TikTokApi/tiktok.py#L486