Search code examples
pythonpython-3.xapitiktok

AttributeError: 'TikTokApi' object has no attribute 'width'


I'm trying to use the library TikTokApi to download TikTok data but when I call any method, it throws:

AttributeError: 'TikTokApi' object has no attribute 'width'

Here is an example of the code I'm running:

from TikTokApi import TikTokApi
api = TikTokApi.get_instance(use_selenium=True)
n_videos = 100
username = 'washingtonpost'
user_videos = api.byUsername(username, count=n_videos)

Same happens if I try this one https://github.com/davidteather/TikTok-Api/blob/master/examples/getAUsersVideos.py


Solution

  • I have the same problem. As David said, this error means that python-playwright or selenium is not launching correctly. What I did is

    1. Check the version of your chrome Right upper corner -> help -> About Google Chrome
    2. Download the chromedriver from chromedriver!
    3. let your API find the driver
    api = TikTokApi.get_instance(use_selenium=True, executablePath="/path/to/chromedriver")