Git Product home page Git Product logo

tiktokapi-python's People

Contributors

avilash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiktokapi-python's Issues

Posting possible?

Hi is posting possible?

Or getting stats like an amount of hashtags "dog" in a day?

Just figuring out what's possible and what not?

api.getLikesByUserName => {'statusCode': 0}

from TikTokAPI import TikTokAPI

cookie = {
  "s_v_web_id": "...",
  "tt_webid": "..."
}

api = TikTokAPI(cookie=cookie)
user_videos = api.getLikesByUserName("my.username")

print(user_videos)

I always get {statusCode: 0} even though my cookie params are valid and my account is public.
Any ideas on how to debug this? Thanks

How to actually get the cookie info

Hi,

i am unable to get the cookie info. I don't know if I am dumb or what but I just cant seem to find it :/ . This is my applications tab screenshot. Please where are the cookies. Thanks in advance.

image

Cookie names not available

In the documentation it says to use the following:

cookie = {
  "s_v_web_id": "<your_key>",
  "tt_webid": "<your_key>"
}

But after logging in to Tiktok, there is no cookie by these names.

Seems like tt_webid has changed to ttwid.
But cant figure out what or where to locate the s_v_web_id

Does anyone know?

Cannot import module

image

i followed all the steps correct in yr readme document, but upon trying to start, I get this error. i do not know how to continue, please advice.

ERROR:root:TikTok response

I have been using this for a week now with no issue. I attempted to pull a video tonight, and I am getting the error above. It will sometimes pull 1 video with out the error then for the remaining return the same error. Haven't seen this and I am not sure what it may even be related to.

Thanks

JSONDecodeError

Hello! I'm trying to do this:

class Bot:
    t: TikTokAPI
    hashtags = [
        'usatiktokers',
        'washington'
    ]

    def __init__(self):
        log.info("Initializing bot...")
        self.t = TikTokAPI(region="US")
        log.info("Initialized.")

    def crawl(self, count: int) -> list:
        log.info(f"Starting crawling for {count} videos...")
        result = []
        count_per_seed = int(count / len(self.hashtags))

        for hashtag in self.hashtags:
            result.extend(self.t.getVideosByHashTag(hashTag=hashtag, count=count_per_seed)['body']['itemListData'])

But i got this:

2020-08-18 00:05:49,348 Initializing bot...
2020-08-18 00:05:49,348 Initialized.
2020-08-18 00:05:49,348 Starting crawling for 1000 videos...
Traceback (most recent call last):
  File "bot.py", line 78, in <module>
    videos = t.crawl(1000)
  File "bot.py", line 42, in crawl
    result.extend(self.t.getVideosByHashTag(hashTag=hashtag, count=count_per_seed)['body']['itemListData'])
  File "/home/claes/.local/share/virtualenvs/tiktok_parser-Bqk8ZjrR/lib/python3.8/site-packages/TikTokAPI/tiktokapi.py", line 157, in getVideosByHashTag
    return self.send_get_request(url, params, extra_headers=extra_headers)
  File "/home/claes/.local/share/virtualenvs/tiktok_parser-Bqk8ZjrR/lib/python3.8/site-packages/TikTokAPI/tiktokapi.py", line 41, in send_get_request
    data = get_req_json(url, params=None, headers=self.headers)
  File "/home/claes/.local/share/virtualenvs/tiktok_parser-Bqk8ZjrR/lib/python3.8/site-packages/TikTokAPI/utils.py", line 28, in get_req_json
    return json.loads(r.text)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It is very strange error, cause sometimes it throwing, sometimes not. With the same parameters.
Can you fix it?

upd: I tried to print(r.text) in TikTokAPI.utils.get_req_json and it shows normal json:

{"statusCode":0,"challengeInfo":{"challenge":{"id":"1638134384680965","title":"usatiktokers","desc":"","profileThumb":"","profileMedium":"","profileLarger":"","coverThumb":"","coverMedium":"","coverLarger":"","isCommerce":false},"stats":{"videoCount":1833,"viewCount":16000000},"shareMeta":{"title":"#usatiktokers on TikTok","desc":"16.0m views - Watch awesome short videos created with trending hashtag #usatiktokers"}}}

Also I've tried to make json.loads() this r.text and it still correct, but with your library not. Hmm..

upd2: Okay. I found that sometimes tiktok sends empty message:

def get_req_json(url, params=None, headers=None):
    r = requests.get(url, params=params, headers=headers)
    resp_str = r.content.decode()
    print(f'"{resp_str}"')
    resp = json.loads(r.content.decode())
    return resp

Output:

"{"statusCode":0,"challengeInfo":{"challenge":{"id":"1638134384680965","title":"usatiktokers","desc":"","profileThumb":"","profileMedium":"","profileLarger":"","coverThumb":"","coverMedium":"","coverLarger":"","isCommerce":false},"stats":{"videoCount":1832,"viewCount":16000000},"shareMeta":{"title":"#usatiktokers on TikTok","desc":"16.0m views - Watch awesome short videos created with trending hashtag #usatiktokers"}}}"
""

You can see that second message is empty..
And it is the same request. I'm requesting for usatiktokers hashtag only but it gets 2 response and one of them is empty.
I see that problem in getVideosByHashTag return.
First request is for getHashtag() and second (that empty) it is final request

api.downloadVideoByIdNoWatermark is not working

Hello,
I‘m trying to downloadVideoByIdNoWatermark, it returns a html code with error instead.

def downloadVideoByIdNoWatermark(self, video_id, save_path):
    video_info = self.getVideoById(video_id)
    video_url = video_info["itemInfo"]["itemStruct"]["video"]["downloadAddr"]
    video_data = get_req_text(video_url, params=None, headers=self.headers)
    pos = video_data.find("vid:")
    if pos == -1:
        raise VideoException("Video without watermark not available in new videos")
    video_url_no_wm = "https://api2-16-h2.musical.ly/aweme/v1/play/?video_id={" \
                      "}&vr_type=0&is_play_url=1&source=PackSourceEnum_PUBLISH&media_type=4" \
        .format(video_data[pos + 4:pos + 36])
    print("video_url_no_wm : ")
    print(video_url_no_wm)
    video_data_no_wm = get_req_content(video_url_no_wm, params=None, headers=self.headers)
    print("video_data_no_wm : ")
    print(video_data_no_wm)
    with open(save_path, 'wb') as f:
        f.write(video_data_no_wm)

video_id:
6829613641491418374

video_url_no_wm :
https://api2-16-h2.musical.ly/aweme/v1/play/?video_id=v09044b80000br3qikhe3ejq8khkj6n0&vr_type=0&is_play_url=1&source=PackSourceEnum_PUBLISH&media_type=4

video_data_no_wm :


b'\n<TITLE>Access Denied</TITLE>\n\n

Access Denied

\n \nYou don't have permission to access "/D/11965/819927/000/api2.musical.ly/c2f7c0a5a85fc47409196837f0d0d4d3/6011a5d1/video/tos/useast2a/tos-useast2a-pve-0068/3cb3c791b9c048caaed792fae13091cc/?a=1233&br=8404&bt=4202&cd=0%7C0%7C0&cr=0&cs=0&cv=1&dr=0&ds=6&er=&l=202101271141260101901760164F090CD3&lr=&mime_type=video_mp4&pl=0&qs=0&rc=MzlubnRoaG50dTMzOzczM0ApaTQzPGU7ZWVnN2g3aWc5OGdrZ2U1ZzBlZjBfLS1fMTZzc18tXjIvYGM1MmIxYl5gX2I6Yw%3D%3D&vl=&vr=" on this server.

\nReference #18.f23ca17.1611747688.193a3168\n\n\n'


Why am I getting this issue

Traceback (most recent call last):
File "c:/Users/48606/Desktop/ttbot/skrypt.py", line 26, in
api.downloadVideoById(trendin[i], 'C:\Users\48606\Desktop\ttbot\vids_tmp')
File "C:\Users\48606\AppData\Local\Programs\Python\Python37\lib\site-packages\TikTokAPI\tiktokapi.py", line 242, in downloadVideoById
with open(save_path, 'wb') as f:
PermissionError: [Errno 13] Permission denied: 'C:\Users\48606\Desktop\ttbot\vids_tmp'

I have the newest version

cant scrap

i cannot scrap videos by hashtag/author

getVideosByHashTag api return error code : 10000

getVideosByHashTag returning error code 10000. (Quick googling say it is captcha response.)
Did anyone get this issue. Is there any workaround for this error.

Below is complete response.

{
'code': '10000',
'from': '',
'type': 'verify',
'version': '',
'region': 'va',
'subtype': 'slide',
'detail': 'sVrV5BjaWwvAbqKqTZA-a1C5ydJBfTgj-ilAQfG56o7ZkAqGoiECGDy5Uu9VljNZQ6h9CVKrgnjyNo6BRSKgeOhiohuOBsd8r7c0YeY56GgbJB6ll4ZK9TL1qIibEenHuAPPnOBV3RAsso7GduGpObKQUceNqXuPdDDXiIyg9-zFtPn41UXpYLq5EXzGW6pO0w9QCV0ZOqLH9ttArcmjVE1hejDvK0obvQJxrNbrn8O5pq5ysmdG2k5YmEkfm0gQSMGVOiJqxTfllg-8bQKHW-D1ad9ZQPpKFLw0LjSJbv1Tx8goNutej2zhJbi-uOtEm5Q3RUDc5inOogCO-ZPJeljFuAZc5EV52VJOXEmJcrlKAcZAWaHNybT0qDldTyEp7rdgAl3BjO-xy3fs1twIFdhyEcnl0GtLuOig..',
'verify_event': '',
'fp': 'myfp',
'scene': '',
'verify_ticket': '',
'channel_mobile': '',
'sms_content': '',
'mobile': '',
'email': ''
}

getVideoByUserName

any attemtp to get the user video, custom or not, on multiple types of API, not only this one, now returns StatusCode: '0'. Anyone knows if something recently changes within TikTok, and if there is a solution?

video_data = api.getVideosByUserId(tiktok_user_id, sec_user_id)
app.logger.info('user video_data: %s' % video_data)

response:
INFO in api_service: user video_data: {'statusCode': 0}

Everything else works.

Bug, can't get trending videos

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/erre4/.local/lib/python3.7/site-packages/TikTokAPI/tiktokapi.py", line 95, in getTrending return self.send_get_request(url, params) File "/home/erre4/.local/lib/python3.7/site-packages/TikTokAPI/tiktokapi.py", line 75, in send_get_request data = get_req_json(url, params=None, headers=self.headers) File "/home/erre4/.local/lib/python3.7/site-packages/TikTokAPI/utils.py", line 28, in get_req_json return json.loads(r.text) File "/usr/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

python3.7

code:

from TikTokAPI import TikTokAPI
api = TikTokAPI()
retval = api.getTrending(count=5)

it worked until last week. Found similar issues on the other unofficial tiktok python API, but no one could solve it at the moment.

question related

1-->>is there any limit for making an requests,
2-->>do we need to constantly update "s_v_web_id" and "tt_webid"

Errors on Ubuntu 16.04

I'm trying to use it in my program on Ubuntu 16.04 + Python3.9. On Windows it works good and stable but on Ubuntu it raises such erorrs:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.9/site-packages/TikTokAPI/tiktokapi.py", line 141, in getLikesByUserName
    user_data = self.getUserByName(user_name)
  File "/usr/local/lib/python3.9/site-packages/TikTokAPI/tiktokapi.py", line 114, in getUserByName
    return self.send_get_request(url, params)
  File "/usr/local/lib/python3.9/site-packages/TikTokAPI/tiktokapi.py", line 74, in send_get_request
    signature = self.tiktok_browser.fetch_auth_params(url, language=self.language)
  File "/usr/local/lib/python3.9/site-packages/TikTokAPI/tiktok_browser.py", line 54, in fetch_auth_params
    return asyncio.get_event_loop().run_until_complete(self.async_fetch_auth_params(url, language))
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.9/site-packages/TikTokAPI/tiktok_browser.py", line 57, in async_fetch_auth_params
    browser = await launch(self.options)
  File "/usr/local/lib/python3.9/site-packages/pyppeteer/launcher.py", line 306, in launch
    return await Launcher(options, **kwargs).launch()
  File "/usr/local/lib/python3.9/site-packages/pyppeteer/launcher.py", line 167, in launch
    self.browserWSEndpoint = get_ws_endpoint(self.url)
  File "/usr/local/lib/python3.9/site-packages/pyppeteer/launcher.py", line 226, in get_ws_endpoint
    raise BrowserError('Browser closed unexpectedly:\n')
pyppeteer.errors.BrowserError: Browser closed unexpectedly:

OR

http.client.BadStatusLine: GET /json/version HTTP/1.1

Maybe I made something wrong but I didn't find any issue about it in this repo.

Thanks!

How do I retrieve the most recent video of a user?

I am looking to create a discord bot which allows a command to be run and the most recent video of a particular user is sent. I have read through the docs and cannot find the information I need.
I need the:
Description of the video,
Most recent video,
and a preview of the video (the image that shows up when scrolling though a TikTok profile)

If anyone could assist me with how to do this it would be much appreciated.

is_digg ??

Hey there, i want to know what "is_digg" means..

due on my devices when i like a post it shows up this ( THIS DOESNT SAVE THE LIKE )
status_code":0,"is_digg":1

but on the browser / www.tiktok.com i get this ( THIS DOES SAVE THE LIKE )
status_code":0,"is_digg":0

I unliked around 3k videos in 2 days just you to know.

Hope you guys can help me ; Also comment / follow works on website and on app ( On these ones it does show "is_digg" = 0 )

rate limit

I'm checking for new videos from a specific user every 15min using .getUserByName() but I think my IP was banned because the same script works in another machine and stopped working on the machine it was running. I could not find the info about rate limits on TT docs. Does anyone knows where I can find this info?

The api randomly does not let me get data from the getVideosByUserName method

I have a bot that retrieves the tik tok of an user every minute. But now It just gives this key error:
line 118, in getVideosByUserName user_obj = user_data["userInfo"]["user"] KeyError: 'userInfo'

Here is my code :

def get_tikTok(username):
	api = TikTokAPI(cookie=None)
	videos_obj = api.getVideosByUserName(username, count=3)

/api/commit/item/digg/ cannot run without a certain header

Looks like TikTok added a new header for more blockage. "hTc6j8Njvn" it has a, b, c, d, f. You cant like or follow without adding these header values. I tried debugging from console but there are so many functions. Looks like part of the _sig. Please fix it, thank you.

downloadVideoById() not working

I tried this function and in return I get exception of permission denied. Upon debugging, found out HTML page doesn't display anything because tiktok doesn't give access to our requests.

SSL: CERTIFICATE_VERIFY_FAILED

I always get this Error. Can anybody help me there?
I guess it doesn't work because of the cookie-keys. Which of them are the right one to fill them into the code

Please help me :/

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

When I run test_hashtag.py I get this error:

File "/home/usr/python_tiktok_venv_3/lib/python3.7/site-packages/PyTikTokAPI-0.0.4-py3.7.egg/TikTokAPI/utils.py", line 43, in get_req_json
print(r.json())
File "/home/usr/python_tiktok_venv_3/lib/python3.7/site-packages/requests-2.24.0-py3.7.egg/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It happened even when I tried to perform the test from repl.it.
How can I handle it?

Question: structure of results

Great project, thanks for making it available!

I noticed that when requesting video metadata by username, using getVideosByUserName(), the results have a different structure than when requesting by hashtag, using getVideosByHashTag(). For example, the key for author information is author for the former, and authorInfos for the latter.

I was wondering, is this difference caused by tiktok itself? Is there a way to adjust this (other than parsing the results afterwards)?

RuntimeError: There is no current event loop in thread 'Handler_0'.

Tried

api = TikTokAPI()
video = api.getVideoById('6896523341402737921')
print(video)

got

There is no current event loop in thread 'Handler_0'.
Traceback (most recent call last):
  File "C:\Users\JustP\Documents\GitHub\pyrogram_plugins\venv\lib\site-packages\pyrogram\dispatcher.py", line 210, in handler_worker
    await self.loop.run_in_executor(
  File "C:\Python39\lib\concurrent\futures\thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\JustP\Documents\GitHub\pyrogram_plugins\plugins\tiktok.py", line 9, in tiktok
    video = api.getVideoById('6896523341402737921')
  File "C:\Users\JustP\Documents\GitHub\pyrogram_plugins\venv\lib\site-packages\TikTokAPI\tiktokapi.py", line 224, in getVideoById
    return self.send_get_request(url, params)
  File "C:\Users\JustP\Documents\GitHub\pyrogram_plugins\venv\lib\site-packages\TikTokAPI\tiktokapi.py", line 65, in send_get_request
    signature = self.tiktok_browser.fetch_auth_params(url, language=self.language)
  File "C:\Users\JustP\Documents\GitHub\pyrogram_plugins\venv\lib\site-packages\TikTokAPI\tiktok_browser.py", line 54, in fetch_auth_params
    return asyncio.get_event_loop().run_until_complete(self.async_fetch_auth_params(url, language))
  File "C:\Python39\lib\asyncio\events.py", line 642, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Handler_0'.

Same error I have in WSL2
Also tried video = api.getVideoById(6896523341402737921), but it doesn't help

Getting started

Hello,

I can't start using the API, when I use examples from the readme I encounter some errors.

api = TikTokAPI()
user_obj = api.getUserByName("fcbarcelona")

This is the error
`---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in
1 api = TikTokAPI()
----> 2 user_obj = api.getUserByName("pompeiibrand")

c:\users\aleja\appdata\local\programs\python\python37\lib\site-packages\pytiktokapi-0.0.3-py3.7.egg\TikTokAPI\tiktokapi.py in getUserByName(self, user_name)
70 for key, val in self.default_params.items():
71 params[key] = val
---> 72 return self.send_get_request(url, params)
73
74 def getVideosByUserName(self, user_name, count=30):

c:\users\aleja\appdata\local\programs\python\python37\lib\site-packages\pytiktokapi-0.0.3-py3.7.egg\TikTokAPI\tiktokapi.py in send_get_request(self, url, params, extra_headers)
29 def send_get_request(self, url, params, extra_headers=None):
30 url = build_get_url(url, params)
---> 31 signature = self.tiktok_browser.fetch_auth_params(url, language=self.language)
32 url = build_get_url(url, {self.signature_key: signature}, append=True)
33 if extra_headers is None:

c:\users\aleja\appdata\local\programs\python\python37\lib\site-packages\pytiktokapi-0.0.3-py3.7.egg\TikTokAPI\tiktok_browser.py in fetch_auth_params(self, url, language)
53
54 def fetch_auth_params(self, url, language='en'):
---> 55 return asyncio.get_event_loop().run_until_complete(self.async_fetch_auth_params(url, language))
56
57 async def async_fetch_auth_params(self, url, language):

c:\users\aleja\appdata\local\programs\python\python37\lib\asyncio\base_events.py in run_until_complete(self, future)
561 """
562 self._check_closed()
--> 563 self._check_runnung()
564
565 new_task = not futures.isfuture(future)

c:\users\aleja\appdata\local\programs\python\python37\lib\asyncio\base_events.py in _check_runnung(self)
521 def _check_runnung(self):
522 if self.is_running():
--> 523 raise RuntimeError('This event loop is already running')
524 if events._get_running_loop() is not None:
525 raise RuntimeError(

RuntimeError: This event loop is already running`

Do you know how to fix it?

Kind regards

Comment API response status 3?

What I know

status 2 = failure.
status = 7 is success
wtf is status = 3?

in comment API response.

please advise. thank you

Is this API still working for you ?

Hey i wanted to work with this api but this look like nothing work.
When im trying basic tests from the API, nothing work...

I just got Invalid Argument error with nothing else.
When I'm trying to do make my own functions, that give me error from TikTikAPI class.

Im alone to have this problem ?

Thanks in advance

tt_webid

where can i get the tt_webid ?

TikTokAPI

from TikTokAPI import TikTokAPI
ModuleNotFoundError: No module named 'TikTokAPI'

RuntimeError: this event loop is already running.

@app.route("/")
async def test(request):
data = await getTikTokData('buzoganynorbert23')
return json({"data": data})

Errors:

File "/home/bogdan/.local/share/virtualenvs/sbb-service-QBvzA2s1/lib/python3.7/site-packages/TikTokAPI/tiktok_browser.py", line 62, in fetch_auth_params
return asyncio.get_event_loop().run_until_complete(self.async_fetch_auth_params(url, language))
File "uvloop/loop.pyx", line 1450, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1443, in uvloop.loop.Loop.run_until_complete
File "uvloop/loop.pyx", line 1351, in uvloop.loop.Loop.run_forever
File "uvloop/loop.pyx", line 480, in uvloop.loop.Loop._run
RuntimeError: this event loop is already running.
[2020-11-23 17:22:52 +0200] - (sanic.access)[INFO][127.0.0.1:43530]: GET http://127.0.0.1:5555/ 500 735

This event loop is already running

Hey ! I have a problem that I don't really understand..

This is my code
from TikTokAPI.TikTokAPI import TikTokAPI
api = TikTokAPI()
test = api.getVideosByUserName("creatingwonders")

And this is the error I get but I just don't understand why ..
RuntimeError: This event loop is already running

Thanks in advance

adding offset to getVideosByHashTag count

The problem is I would like to download 100 videos by some hashtag. But I can only download about 35 in one function call. But if I call the function again I will get the same 35 tiktoks. How can I get next 35 (or more) tiktoks?

from TikTokAPI import TikTokAPI
import os

cookie = {
  "s_v_web_id": "",
  "tt_webid": ""
}

api = TikTokAPI(cookie=cookie)
# count = 20 works, but count = 100 doesn't work! 
retval = api.getVideosByHashTag("funny", count=20)

directory = "funny_hashtag"
if not os.path.isdir(directory):
  os.mkdir(directory)
print(retval)

for tiktok in retval['itemList']:
  video_data = api.downloadVideoById(str(tiktok['id']), f"{directory}/{tiktok['id']}.mp4")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.