POST /scrapping
Initiates the scraping process by fetching purchase data from the Corprecam system and submitting it to Siigo.Request
The purchase code (com_codigo) to process. This identifier is used to fetch the purchase record and its associated items from the Corprecam system.
Request Example
Process Flow
When this endpoint is called, it performs the following operations:- Fetch Purchase Data - Retrieves the main purchase record using
getCompras() - Fetch Purchase Items - Gets all line items for the purchase using
getCompraItems() - Fetch Materials - Retrieves material details for each item using
getMateriales() - Fetch Micro Route - Gets the micro route information using
getMicro() - Transform Data - Converts the data into Siigo DocumentoSoporte format
- Execute Playwright - Automates the Siigo web interface to submit the data
Response
Status message indicating successful processing. Returns “ok” when the scraping process completes successfully.
Response Example
Status Codes
- 200 - Success: The purchase data was processed and submitted to Siigo successfully
- 500 - Internal Server Error: An error occurred during data fetching or processing
Implementation Details
The endpoint implementation (server.ts:21-41):Notes
- The endpoint uses CORS and accepts JSON payloads
- All data fetching operations are performed sequentially
- The purchase code is used to query multiple related datasets
- Material IDs are extracted from purchase items before fetching material details
- The micro route ID is extracted from the purchase record and converted to a number
- The endpoint waits for the Playwright automation to complete before responding