From: Claromes Date: Sun, 16 Jun 2024 00:04:30 +0000 (-0300) Subject: update docs X-Git-Url: https://git.claromes.com/?a=commitdiff_plain;h=53e99939740d7c1d05649a9d70a092f8578562dd;p=waybacktweets.git update docs --- diff --git a/README.md b/README.md index 935553b..5a8890f 100644 --- a/README.md +++ b/README.md @@ -23,20 +23,26 @@ waybacktweets --from 20150101 --to 20191231 --limit 250 jack ### Using Wayback Tweets as a Python Module ```python -from waybacktweets import WaybackTweets -from waybacktweets.utils import parse_date +from waybacktweets import WaybackTweets, TweetsParser, TweetsExporter -username = "jack" -collapse = "urlkey" -timestamp_from = parse_date("20150101") -timestamp_to = parse_date("20191231") -limit = 250 -offset = 0 -matchtype = "exact" - -api = WaybackTweets(username, collapse, timestamp_from, timestamp_to, limit, offset, matchtype) +USERNAME = "jack" +api = WaybackTweets(USERNAME) archived_tweets = api.get() + +if archived_tweets: + field_options = [ + "archived_timestamp", + "original_tweet_url", + "archived_tweet_url", + "archived_statuscode", + ] + + parser = TweetsParser(archived_tweets, USERNAME, field_options) + parsed_tweets = parser.parse() + + exporter = TweetsExporter(parsed_tweets, USERNAME, field_options) + exporter.save_to_csv() ``` ### Using Wayback Tweets as a Web App diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 8700ee3..f98a503 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -20,21 +20,27 @@ Using Wayback Tweets as a Python Module .. code-block:: python - from waybacktweets import WaybackTweets - from waybacktweets.utils import parse_date + from waybacktweets import WaybackTweets, TweetsParser, TweetsExporter - username = "jack" - collapse = "urlkey" - timestamp_from = parse_date("20150101") - timestamp_to = parse_date("20191231") - limit = 250 - offset = 0 - matchtype = "exact" - - api = WaybackTweets(username, collapse, timestamp_from, timestamp_to, limit, offset, matchtype) + USERNAME = "jack" + api = WaybackTweets(USERNAME) archived_tweets = api.get() + if archived_tweets: + field_options = [ + "archived_timestamp", + "original_tweet_url", + "archived_tweet_url", + "archived_statuscode", + ] + + parser = TweetsParser(archived_tweets, USERNAME, field_options) + parsed_tweets = parser.parse() + + exporter = TweetsExporter(parsed_tweets, USERNAME, field_options) + exporter.save_to_csv() + Web App ------------- diff --git a/docs/todo.rst b/docs/todo.rst index 1dce342..cda3ea5 100644 --- a/docs/todo.rst +++ b/docs/todo.rst @@ -13,3 +13,7 @@ TODO |uncheck| Code: Develop a scraper to download snapshots from https://archive.today (`Not planned`) +|uncheck| Code: Unit Tests (`Planned`) + +|uncheck| Code: Mapping and parsing of other Twitter-related URLs (`Planned`) + diff --git a/waybacktweets/api/export_tweets.py b/waybacktweets/api/export_tweets.py index cb789f6..4cd5d83 100644 --- a/waybacktweets/api/export_tweets.py +++ b/waybacktweets/api/export_tweets.py @@ -14,8 +14,8 @@ class TweetsExporter: :param data: The parsed archived tweets data. :param username: The username associated with the tweets. - :param field_options: The fields to be included in the exported data. - """ + :param field_options: The fields to be included in the exported data. Options include "archived_urlkey", "archived_timestamp", "original_tweet_url", "archived_tweet_url", "parsed_tweet_url", "parsed_archived_tweet_url", "available_tweet_text", "available_tweet_is_RT", "available_tweet_info", "archived_mimetype", "archived_statuscode", "archived_digest", "archived_length". + """ # noqa: E501 def __init__( self, data: Dict[str, List[Any]], username: str, field_options: List[str] diff --git a/waybacktweets/api/parse_tweets.py b/waybacktweets/api/parse_tweets.py index e42f6c5..28404e8 100644 --- a/waybacktweets/api/parse_tweets.py +++ b/waybacktweets/api/parse_tweets.py @@ -147,8 +147,8 @@ class TweetsParser: :param archived_tweets_response: The response from the archived tweets. :param username: The username associated with the tweets. - :param field_options: The fields to be included in the parsed data. - """ + :param field_options: The fields to be included in the parsed data. Options include "archived_urlkey", "archived_timestamp", "original_tweet_url", "archived_tweet_url", "parsed_tweet_url", "parsed_archived_tweet_url", "available_tweet_text", "available_tweet_is_RT", "available_tweet_info", "archived_mimetype", "archived_statuscode", "archived_digest", "archived_length". + """ # noqa: E501 def __init__( self,