Collecting data for certain users #1038
Unanswered
NicolasRuth
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First, thanks for the update to v. 6.0.1!
I wanted to collect some data on musicians from the top 100 TikTok accounts (by followers). I did this two years ago, using the old version of TikTokApi:
`musicians = ["willsmith", "lorengray", "jasonderulo", "bts_official_bighit", "lilhuddy", "selenagomez", "billieeilish",
"arianagrande", "justinbieber", "karolsevillaokay", "mackenzieziegler", "marshmellomusic",
"blackpinkofficial", "lelepons", "camilo", "larrayeeee", "jacobsartorius", "itsjojosiwa", "babyariel",
"kimberly.loaiza"]
tiktok_data = [api.get_user(username=musician, custom_verifyFp="insert_your_custom_verifyFb_here")
for musician in musicians]
data = pandas.DataFrame(tiktok_data)
data.to_csv('tiktokdata.csv')`
I wanted to do the same thing with version 6 but run into an error. It says KeyError: 'user'. The code I tried looks like this.
`musicians2023 = ["Bella Poarch", "Kimberly Loaiza", "Will Smith", "BTS", "Selena Gomez", "Jason Derulo",
"dixie", "Spencer X", "Loren Gray", "BILLIE EILISH", "Karol G", "JoJo Siwa", "blackpinkofficial",
"ROSÉ", "Shakira", "BabyAriel", "Q Park", "KEEMOKAZI", "JD Pantoja", "Ruben Tuesta", "La Rosalia",
"arianagrande", "Lele Pons", "Huddy", "Bad Bunny", "Kira Kosarin", "Naimdarrechi", "Camilo"]
async def user_info():
async with TikTokApi() as api:
await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3)
user = api.user(musician)
user_data = await user.info()
print(user_data)
for musician in musicians2023:
asyncio.run(user_info())
tiktok_data_2023 = user_data
data_2023 = pd.DataFrame(tiktok_data_2023)
data_2023.to_csv('tiktokdata.csv') `
I am sure I did something wrong. I am not too experienced with Python. Could anyone help, please?
Beta Was this translation helpful? Give feedback.
All reactions