Submits multiple asynchronous tasks to the server in a batch. :param tasks: A list of dictionaries, each containing the scraper's input data. :param scraper_name: The name of the scraper to use for the tasks. If not provided, the server will use the default scraper.
(self, data_items, scraper_name=None)
| 104 | return response_data |
| 105 | |
| 106 | def create_async_tasks(self, data_items, scraper_name=None): |
| 107 | """ |
| 108 | Submits multiple asynchronous tasks to the server in a batch. |
| 109 | |
| 110 | :param tasks: A list of dictionaries, each containing the scraper's input data. |
| 111 | :param scraper_name: The name of the scraper to use for the tasks. If not provided, the server will use the default scraper. |
| 112 | :return: A list of created task objects. |
| 113 | """ |
| 114 | url = self._make_api_url("api/tasks/create-task-async") |
| 115 | # Prepare the payload as a list of tasks, each with its data and optional scraper_name |
| 116 | payload = [{"data": data, "scraper_name": scraper_name} for data in data_items] |
| 117 | response = requests.post(url, json=payload) |
| 118 | _raise_for_status(response) |
| 119 | response_data = response.json() |
| 120 | self._write_json("create_async_tasks", response_data) # Call write_json with method name |
| 121 | return response_data |
| 122 | |
| 123 | def create_sync_tasks(self, data_items, scraper_name=None): |
| 124 | """ |
nothing calls this directly
no test coverage detected