Add reverse to snapshots()
Add the option to get snapshots in reverse (from newest to oldest). This is especially useful since the snapshots() method returns a generator!
This commit is contained in:
		| @@ -336,7 +336,7 @@ class WaybackMachineCDXServerAPI: | ||||
|         """ | ||||
|         return self.near(year=1994, month=1, day=1) | ||||
|  | ||||
|     def snapshots(self) -> Generator[CDXSnapshot, None, None]: | ||||
|     def snapshots(self, reverse: bool = False) -> Generator[CDXSnapshot, None, None]: | ||||
|         """ | ||||
|         This function yields the CDX data lines as snapshots. | ||||
|  | ||||
| @@ -373,6 +373,9 @@ class WaybackMachineCDXServerAPI: | ||||
|             # at once, thus there should be no issues of too much memory usage. | ||||
|             snapshot_list = entry.split("\n") | ||||
|  | ||||
|             if reverse: | ||||
|                 snapshot_list.reverse() | ||||
|  | ||||
|             for snapshot in snapshot_list: | ||||
|  | ||||
|                 # 14 + 32 == 46 ( timestamp + digest ), ignore the invalid entries. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user