st.session_state.archived_timestamp_filter[0],
st.session_state.archived_timestamp_filter[1],
tweets_per_page,
+ st.session_state.offset,
)
archived_tweets = response.get()
help="Filtering by date range up to this date.",
)
@click.option("--limit", type=int, default=None, help="Query result limits.")
-def cli(username, unique, timestamp_from, timestamp_to, limit):
+@click.option(
+ "--offset",
+ type=int,
+ default=None,
+ help="Allows for a simple way to scroll through the results.",
+)
+def cli(username, unique, timestamp_from, timestamp_to, limit, offset):
"""
Retrieves archived tweets' CDX data from the Wayback Machine,
performs necessary parsing, and saves the data.
USERNAME: The Twitter username without @.
"""
try:
- api = WaybackTweets(username, unique, timestamp_from, timestamp_to, limit)
+ api = WaybackTweets(
+ username, unique, timestamp_from, timestamp_to, limit, offset
+ )
archived_tweets = api.get()
if archived_tweets:
class WaybackTweets:
"""Requests data from the Wayback CDX Server API and returns it in JSON format."""
- def __init__(self, username, unique, timestamp_from, timestamp_to, limit):
+ def __init__(self, username, unique, timestamp_from, timestamp_to, limit, offset):
self.username = username
self.unique = unique
self.timestamp_from = timestamp_from
self.timestamp_to = timestamp_to
self.limit = limit
+ self.offset = offset
def get(self):
"""GET request to the Internet Archive's CDX API to retrieve archived tweets."""
if self.limit:
params["limit"] = self.limit
+ if self.offset:
+ params["offset"] = self.offset
+
print("Making a request to the Internet Archive...")
try: