Submits an asynchronous 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)
| 66 | api = Api('https://example.com')""".format(self._api_url)) |
| 67 | |
| 68 | def create_async_task(self, data, scraper_name=None): |
| 69 | """ |
| 70 | Submits an asynchronous task to the server. |
| 71 | |
| 72 | :param data: The data to be processed by the task. |
| 73 | :param scraper_name: The name of the scraper to use for the task. If not provided, the server will use the default scraper. |
| 74 | :return: The created task object. |
| 75 | """ |
| 76 | url = self._make_api_url("api/tasks/create-task-async") |
| 77 | payload = { |
| 78 | "data": data, |
| 79 | "scraper_name": scraper_name, |
| 80 | } |
| 81 | response = requests.post(url, json=payload) |
| 82 | _raise_for_status(response) |
| 83 | response_data = response.json() |
| 84 | self._write_json("create_async_task", response_data) # Call write_json with method name |
| 85 | return response_data |
| 86 | |
| 87 | def create_sync_task(self, data, scraper_name=None): |
| 88 | """ |
nothing calls this directly
no test coverage detected