wayback_client 0.1.0
wayback_client: ^0.1.0 copied to clipboard
A Dart client for the Internet Archive's Wayback Machine Save Page Now API. Easily archive web pages and check if snapshots are cached.
example/wayback_client_example.dart
import 'package:dio/dio.dart';
import 'package:wayback_client/wayback_client.dart';
Future<void> main() async {
// 1. Set up a custom Dio client (with timeouts and headers)
final dio = Dio(BaseOptions(connectTimeout: const Duration(seconds: 10)));
// 2. Create the client with custom configuration
final client = WaybackClient(
dio: dio,
maxRetries: 5, // Reduce retries for the example
userAgent:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
);
try {
// 3. Archive a URL
final (archiveUrl, isCached) = await client.saveUrl(
'https://dart.dev/effective-dart',
);
print('📁 Result:');
print(' - Snapshot URL: $archiveUrl');
print(' - Content cached? ${isCached ? '✅ Yes' : '❌ No'}');
print(' - You can view it at: $archiveUrl');
} catch (e) {
print('⚠️ Failed to archive the URL: $e');
}
}