scheduleJob method
void
scheduleJob({})
Schedules a scraping job
id is the unique identifier for the job
url is the URL to scrape
interval is the interval between runs in milliseconds
selectors is a map of field names to CSS selectors
attributes is a map of field names to attributes to extract (optional)
storeResults whether to store the results in the data storage manager
onResult is a callback for handling the results
onError is a callback for handling errors
Implementation
void scheduleJob({
required String id,
required String url,
required int interval,
required Map<String, String> selectors,
Map<String, String?>? attributes,
bool storeResults = true,
void Function(List<Map<String, String>>)? onResult,
void Function(Exception)? onError,
}) {
_jobScheduler.scheduleJob(
id: id,
url: url,
interval: interval,
selectors: selectors,
attributes: attributes,
onResult: (results) {
if (storeResults) {
_storageManager.storeStructuredData(id, url, results);
}
onResult?.call(results);
},
onError: onError,
);
}