MCPcopy Index your code
hub / github.com/omkarcloud/botasaurus / create_sync_tasks

Method create_sync_tasks

botasaurus_api/botasaurus_api/__init__.py:123–138  ·  view source on GitHub ↗

Submits multiple synchronous tasks to the server in a batch and waits for the results. :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

(self, data_items, scraper_name=None)

Source from the content-addressed store, hash-verified

121 return response_data
122
123 def create_sync_tasks(self, data_items, scraper_name=None):
124 """
125 Submits multiple synchronous tasks to the server in a batch and waits for the results.
126
127 :param tasks: A list of dictionaries, each containing the scraper's input data.
128 :param scraper_name: The name of the scraper to use for the tasks. If not provided, the server will use the default scraper.
129 :return: A list of created task objects, each with its processing result.
130 """
131 url = self._make_api_url("api/tasks/create-task-sync")
132 # Prepare the payload as a list of tasks, each with its data and optional scraper_name
133 payload = [{"data": data, "scraper_name": scraper_name} for data in data_items]
134 response = requests.post(url, json=payload)
135 _raise_for_status(response)
136 response_data = response.json()
137 self._write_json("create_sync_tasks", response_data) # Call write_json with method name
138 return response_data
139
140 def get_tasks(self, page=1, per_page=None, with_results=True):
141 """

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