Submits a synchronous task to the server. :param data: The data to be processed by the task. :param scraper_name: The name of the scraper to use for the task. If not provided, the server will use the default scraper. :return: The created task object.
(self, data, scraper_name=None)
| 85 | return response_data |
| 86 | |
| 87 | def create_sync_task(self, data, scraper_name=None): |
| 88 | """ |
| 89 | Submits a synchronous task to the server. |
| 90 | |
| 91 | :param data: The data to be processed by the task. |
| 92 | :param scraper_name: The name of the scraper to use for the task. If not provided, the server will use the default scraper. |
| 93 | :return: The created task object. |
| 94 | """ |
| 95 | url = self._make_api_url("api/tasks/create-task-sync") |
| 96 | payload = { |
| 97 | "data": data, |
| 98 | "scraper_name": scraper_name, |
| 99 | } |
| 100 | response = requests.post(url, json=payload) |
| 101 | _raise_for_status(response) |
| 102 | response_data = response.json() |
| 103 | self._write_json("create_sync_task", response_data) # Call write_json with method name |
| 104 | return response_data |
| 105 | |
| 106 | def create_async_tasks(self, data_items, scraper_name=None): |
| 107 | """ |
nothing calls this directly
no test coverage detected