diff --git a/changedetectionio/fetch_site_status.py b/changedetectionio/fetch_site_status.py index bee0d50c..7437d7fe 100644 --- a/changedetectionio/fetch_site_status.py +++ b/changedetectionio/fetch_site_status.py @@ -15,6 +15,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) class perform_site_check(): screenshot = None xpath_data = None + fetched_response = None def __init__(self, *args, datastore, **kwargs): super().__init__(*args, **kwargs) @@ -131,6 +132,7 @@ class perform_site_check(): self.screenshot = fetcher.screenshot self.xpath_data = fetcher.xpath_data + self.fetched_response = fetcher.content # Fetching complete, now filters # @todo move to class / maybe inside of fetcher abstract base? diff --git a/changedetectionio/store.py b/changedetectionio/store.py index 00e568df..82e926ae 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -375,6 +375,17 @@ class ChangeDetectionStore: f.write(json.dumps(data)) f.close() + # Save whatever was returned from the fetcher + def save_last_response(self, watch_uuid, data): + if not self.data['watching'].get(watch_uuid): + return + + target_path = os.path.join(self.datastore_path, watch_uuid, "last-response.bin") + # mimetype? binary? text? @todo + # gzip if its non-binary? auto get encoding? + with open(target_path, 'wb') as f: + f.write(data) + f.close() def sync_to_json(self): logging.info("Saving JSON..") diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index d56a9298..2f64d41b 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -286,6 +286,9 @@ class update_worker(threading.Thread): self.datastore.save_screenshot(watch_uuid=uuid, screenshot=update_handler.screenshot) if update_handler.xpath_data: self.datastore.save_xpath_data(watch_uuid=uuid, data=update_handler.xpath_data) + if update_handler.fetched_response: + # @todo mimetype? + self.datastore.save_last_response(watch_uuid=uuid, data=update_handler.fetched_response) self.current_uuid = None # Done