This API server handles PDF extraction from the Karnataka Land Records website using Puppeteer, matching the behavior of the working test script.
-
Install dependencies:
npm install express cors puppeteer
-
Start the API server:
npm run api
Or directly:
node api/server.js
-
The server will run on:
http://localhost:3000
Get PDF URL for a village map.
Request Body:
{
"district": "2",
"taluk": "1",
"hobli": "1",
"village": "ALABALA"
}Success Response:
{
"success": true,
"pdfUrl": "https://landrecords.karnataka.gov.in/service3/FileDownload.aspx?file=..."
}Error Response:
{
"success": false,
"error": "PDF URL not found. Please check your selections."
}Health check endpoint.
Response:
{
"status": "ok",
"timestamp": "2024-01-01T12:00:00.000Z"
}- Uses Puppeteer to automate browser interaction
- Fills the form with provided parameters
- Clicks search button
- Waits for results grid
- Extracts PDF URL from button onclick or popup
- Returns PDF URL to the app
The app now calls this API instead of using WebView. The API handles all the complex browser automation, and the app just receives the PDF URL.
- API not responding: Make sure the server is running (
npm run api) - Connection refused: Check if port 3000 is available
- PDF not found: Verify the parameters match the data in
complete-karnataka-data-filtered.json