### 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
.. 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
-------------
|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`)
+
: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]
: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,