diff --git a/TikTok/TikTok_Get_keyword_trending_songs.ipynb b/TikTok/TikTok_Get_keyword_trending_songs.ipynb index 6cf0d3d6c6..965b93427e 100644 --- a/TikTok/TikTok_Get_keyword_trending_songs.ipynb +++ b/TikTok/TikTok_Get_keyword_trending_songs.ipynb @@ -40,7 +40,7 @@ "id": "0de144be-594d-463e-9849-696fb2f6d1a8", "metadata": {}, "source": [ - "**Last update:** 2024-06-20 (Created: 2024-06-20)" + "**Last update:** 2024-06-28 (Created: 2024-06-20)" ] }, { @@ -48,7 +48,7 @@ "id": "31ea7cdb-e10d-43fc-b026-f69249a59736", "metadata": {}, "source": [ - "**Description:** This notebook demonstrates how to extract the top trending songs on top trending platform, TikTok, by keyword." + "**Description:** This notebook demonstrates how to extract the top trending songs on top trending platform, TikTok, by keyword. You need to create a free account and [rent an Actor](https://console.apify.com/actors/GdWCkxBtKWOsKjdch/input) to start playing with this template." ] }, { @@ -82,7 +82,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "potential-surfing", "metadata": { "tags": [] @@ -96,16 +96,7 @@ " from apify_client import ApifyClient\n", "except:\n", " !pip install --user apify-client\n", - " from apify_client import ApifyClient" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "52badee0", - "metadata": {}, - "outputs": [], - "source": [ + " from apify_client import ApifyClient\n", "nest_asyncio.apply()" ] }, @@ -116,16 +107,15 @@ "source": [ "### Setup variables\n", "\n", - "\n", "**Mandatory**\n", - "- `APIFY_API_TOKEN`: This variable represents the API token required to access the Apify TikTok Scraper API. You can obtain this token by signing up on the Apify platform.\n", - "- `searchQueries`: This variable represents the keywords for which you want to extract the top trending songs on TikTok.\n", - "\n", + "- `APIFY_API_TOKEN`: API token required to access the [Apify TikTok Scraper API](https://console.apify.com/settings/integrations)\n", + "- `searchQueries`: Keywords for which you want to extract the top trending songs on TikTok.\n", + "- `csv_output`: CSV file path to be saved as output.\n", "\n", "**Optional**\n", "\n", - "- `hashtags`: This variable represents the hashtags you want to search for in the TikTok videos. If not provided, the default value is `None`.\n", - "- `resultsPerPage`: This variable represents the number of results per page. If not provided, the default value is `100`." + "- `hashtags`: Hashtags you want to search for in the TikTok videos. If not provided, the default value is `None`.\n", + "- `resultsPerPage`: Number of results per page. If not provided, the default value is `100`." ] }, { @@ -138,14 +128,15 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "continuous-melbourne", "metadata": {}, "outputs": [], "source": [ "# Mandatory\n", - "APIFY_API_TOKEN = 'apify_api_...'\n", + "APIFY_API_TOKEN = 'apify_api_xxxx'\n", "searchQueries = ['afrobeat']\n", + "csv_output = 'trending_songs.csv'\n", "\n", "# Optional - modify if desired\n", "hashtags = []\n", @@ -159,6 +150,14 @@ "}" ] }, + { + "cell_type": "markdown", + "id": "registered-showcase", + "metadata": {}, + "source": [ + "## Model" + ] + }, { "cell_type": "markdown", "id": "af18cb32", @@ -169,7 +168,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "11dc686a", "metadata": {}, "outputs": [], @@ -177,14 +176,6 @@ "client = ApifyClient(APIFY_API_TOKEN)" ] }, - { - "cell_type": "markdown", - "id": "registered-showcase", - "metadata": {}, - "source": [ - "## Model" - ] - }, { "cell_type": "markdown", "id": "tested-astrology", @@ -195,7 +186,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "crude-louisville", "metadata": { "papermill": {}, @@ -242,7 +233,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "31247107", "metadata": {}, "outputs": [], @@ -377,21 +368,10 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "9c4e3b7b-6440-4844-8054-265f1aec65eb", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The input is: \n", - " {'hashtags': [], 'resultsPerPage': 5, 'searchQueries': ['afrobeat']}\n", - "Searching for songs with keyword: ['afrobeat']\n", - "Actor run completed successfully, with id: rNAd6YRwX6Bd9UssA\n" - ] - } - ], + "outputs": [], "source": [ "print(f\"The input is: \\n\", RUN_INPUT)\n", "response = get_songs_by_keyword(RUN_INPUT)" @@ -407,257 +387,15 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "8479fff7", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Extracting data from response\n", - "Data extracted successfully\n" - ] - }, - { - "data": { - "text/html": [ - "
\n", - " | ENTITY | \n", - "SCENARIO | \n", - "SOURCE | \n", - "PUBLISHED_DATE | \n", - "DATE & TIME | \n", - "ID | \n", - "TITLE | \n", - "TEXT | \n", - "CONCEPT | \n", - "SENTIMENT | \n", - "... | \n", - "URL | \n", - "DATE_EXTRACT | \n", - "SCENARIO_ORDER | \n", - "MUSIC_NAME | \n", - "MUSIC_AUTHOR | \n", - "MUSIC_ORIGINAL | \n", - "MUSIC_ALBUM | \n", - "MUSIC_PLAY_URL | \n", - "MUSIC_COVER_MEDIUM_URL | \n", - "MUSIC_ID | \n", - "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", - "son original | \n", - "Trending afrobeat Songs on TikTok | \n", - "TikTok | \n", - "2023-03-09T17:43:04.000Z | \n", - "2024-06-21T09:16:28.000Z | \n", - "7208603444557450501 | \n", - "son original | \n", - "Yeah i need a MOTIVE #fyp #afrobeats #trending... | \n", - "NaN | \n", - "NaN | \n", - "... | \n", - "https://www.tiktok.com/@itzh4ze/video/72086034... | \n", - "2024-06-21 | \n", - "NaN | \n", - "son original | \n", - "DJ Phaphane | \n", - "1.0 | \n", - "\n", - " | \n", - " | https://p16-sign-useast2a.tiktokcdn.com/tos-us... | \n", - "7063182037963787013 | \n", - "
1 | \n", - "original sound | \n", - "Trending afrobeat Songs on TikTok | \n", - "TikTok | \n", - "2023-07-11T16:07:57.000Z | \n", - "2024-06-21T09:16:28.000Z | \n", - "7254593493585104155 | \n", - "original sound | \n", - "The vibe is just right 👌🏼🔥 @IFETE ⏳ #afrobeats... | \n", - "NaN | \n", - "NaN | \n", - "... | \n", - "https://www.tiktok.com/@afrodance.1/video/7254... | \n", - "2024-06-21 | \n", - "NaN | \n", - "original sound | \n", - "Afro Dance | \n", - "1.0 | \n", - "\n", - " | \n", - " | https://p16-sign-va.tiktokcdn.com/tos-maliva-a... | \n", - "7254593439345036059 | \n", - "
2 | \n", - "DJ Phaphane Mashup Afrobeats 2022 | \n", - "Trending afrobeat Songs on TikTok | \n", - "TikTok | \n", - "2023-12-05T23:01:28.000Z | \n", - "2024-06-21T09:16:28.000Z | \n", - "7309249546570288417 | \n", - "DJ Phaphane Mashup Afrobeats 2022 | \n", - "If you got them all we are offically friends🤝💙... | \n", - "NaN | \n", - "NaN | \n", - "... | \n", - "https://www.tiktok.com/@jacobworth01/video/730... | \n", - "2024-06-21 | \n", - "NaN | \n", - "DJ Phaphane Mashup Afrobeats 2022 | \n", - "DJ Phaphane | \n", - "1.0 | \n", - "\n", - " | \n", - " | https://p16-sign-useast2a.tiktokcdn.com/tos-us... | \n", - "7172939294423321349 | \n", - "
3 | \n", - "Sip (Alcohol) | \n", - "Trending afrobeat Songs on TikTok | \n", - "TikTok | \n", - "2023-03-19T10:33:07.000Z | \n", - "2024-06-21T09:16:28.000Z | \n", - "7212203499260529926 | \n", - "Sip (Alcohol) | \n", - "#joeboy #sip #alcohol #songlyrics #afrobeats #... | \n", - "NaN | \n", - "NaN | \n", - "... | \n", - "https://www.tiktok.com/@kingflickr/video/72122... | \n", - "2024-06-21 | \n", - "NaN | \n", - "Sip (Alcohol) | \n", - "Joeboy | \n", - "0.0 | \n", - "Sip (Alcohol) | \n", - "\n", - " | https://p16-va-default.akamaized.net/img/tos-u... | \n", - "7000724233064024066 | \n", - "
4 | \n", - "original sound | \n", - "Trending afrobeat Songs on TikTok | \n", - "TikTok | \n", - "2024-02-04T13:47:49.000Z | \n", - "2024-06-21T09:16:28.000Z | \n", - "7331743101570108677 | \n", - "original sound | \n", - "#ayrastarr #commas #lyricsvideo #afrobeats #af... | \n", - "NaN | \n", - "NaN | \n", - "... | \n", - "https://www.tiktok.com/@lyricsvillla/video/733... | \n", - "2024-06-21 | \n", - "NaN | \n", - "original sound | \n", - "lyrics villa | \n", - "1.0 | \n", - "\n", - " | \n", - " | https://p16-sign-va.tiktokcdn.com/tos-maliva-a... | \n", - "7331743124488899333 | \n", - "
5 rows × 39 columns
\n", - "