MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / create_async_tasks

Method create_async_tasks

botasaurus_api/botasaurus_api/__init__.py:106–121  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers

nothing calls this directly

Calls 3

_make_api_urlMethod · 0.95
_write_jsonMethod · 0.95
_raise_for_statusFunction · 0.85

Tested by

no test coverage detected