scheduleJob method

void scheduleJob({
  1. required String id,
  2. required String url,
  3. required int interval,
  4. required Map<String, String> selectors,
  5. Map<String, String?>? attributes,
  6. bool storeResults = true,
  7. void onResult(
    1. List<Map<String, String>>
    )?,
  8. void onError(
    1. Exception
    )?,
})

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,
  );
}