forked from Saikamesh/tt_crawl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: removing Photo posts & duplicates | v 0.0.28
- Loading branch information
Showing
7 changed files
with
113 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
certifi==2023.11.17 | ||
charset-normalizer==3.3.2 | ||
docutils==0.20.1 | ||
idna==3.6 | ||
importlib-metadata==7.0.1 | ||
jaraco.classes==3.3.0 | ||
keyring==24.3.0 | ||
markdown-it-py==3.0.0 | ||
mdurl==0.1.2 | ||
more-itertools==10.2.0 | ||
nh3==0.2.15 | ||
numpy==1.26.4 | ||
pandas==2.1.4 | ||
pkginfo==1.9.6 | ||
Pygments==2.17.2 | ||
python-dateutil==2.8.2 | ||
pytz==2024.1 | ||
pywin32-ctypes==0.2.2 | ||
readme-renderer==42.0 | ||
requests==2.31.0 | ||
requests-toolbelt==1.0.0 | ||
rfc3986==2.0.0 | ||
rich==13.7.0 | ||
six==1.16.0 | ||
tzdata==2023.3 | ||
twine==4.0.2 | ||
tzdata==2024.1 | ||
urllib3==2.1.0 | ||
zipp==3.17.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import requests | ||
import pandas as pd | ||
|
||
|
||
def validate_urls(response_json: dict) -> dict: | ||
""" | ||
Removes all the photo posts from the data. | ||
Args: | ||
response_json (dict): The response object from the TikTok API. | ||
""" | ||
|
||
EMBED_URL = "https://www.tiktok.com/embed/" | ||
|
||
for video in response_json["data"]["videos"]: | ||
url = EMBED_URL + str(video["id"]) | ||
res = requests.get(url) | ||
|
||
if not res.ok: | ||
response_json["data"]["videos"].remove(video) | ||
|
||
return response_json | ||
|
||
|
||
def remove_duplicate_rows(file) -> None: | ||
""" | ||
Removes duplicate rows from a CSV file. | ||
Args: | ||
file (string): The path of the file with name. | ||
""" | ||
df = pd.read_csv(file) | ||
duplicate_data = df[df.id.duplicated()] | ||
if duplicate_data.empty: | ||
return | ||
df.drop_duplicates(subset="id", keep="first", inplace=True) | ||
df.to_csv(file, index=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.