|
|
8 달 전 | |
|---|---|---|
| scripts | 8 달 전 | |
| src | 8 달 전 | |
| .env.example | 8 달 전 | |
| .gitignore | 8 달 전 | |
| .mcp-gogs.json | 8 달 전 | |
| README.md | 8 달 전 | |
| package.json | 8 달 전 | |
| tsconfig.json | 8 달 전 |
A TypeScript-based web scraper for extracting information from webshops (ShopRenter, WooCommerce, Shopify). The application provides a REST API for submitting scraping jobs and retrieving results.
Clone the repository:
git clone <repository-url>
cd webshop-scraper
Run the installation script:
sudo ./scripts/install.sh
The script will:
Install dependencies:
npm install
Build the application:
npm run build
Create a .env file:
cp .env.example .env
Edit .env and set your configuration:
API_KEY=your-secret-key-here
PORT=3000
MAX_CONCURRENT_JOBS=3
Start the application:
npm start
sudo systemctl start webshop-scraper
sudo systemctl stop webshop-scraper
sudo journalctl -u webshop-scraper -f
All API endpoints (except /health) require Bearer authentication.
GET /health
Example:
curl http://localhost:3000/health
POST /api/jobs
Authorization: Bearer <your-api-key>
Content-Type: application/json
{
"url": "https://example-shop.com"
}
Example:
curl -X POST http://localhost:3000/api/jobs \
-H "Authorization: Bearer your-secret-key-here" \
-H "Content-Type: application/json" \
-d '{"url": "https://example-shop.com"}'
Response:
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "pending",
"message": "Job created successfully"
}
GET /api/jobs/:id
Authorization: Bearer <your-api-key>
Example:
curl http://localhost:3000/api/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
-H "Authorization: Bearer your-secret-key-here"
Response (when completed):
{
"job_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "completed",
"created_at": "2024-01-01T12:00:00.000Z",
"updated_at": "2024-01-01T12:05:00.000Z",
"result": {
"initial_sitemap": "https://example-shop.com/sitemap.xml",
"shipping_informations": {
"url": "https://example-shop.com/shipping",
"content": "# Shipping Information\n\n..."
},
"contacts": {
"url": "https://example-shop.com/contact",
"content": "# Contact Us\n\n..."
},
"terms_of_conditions": {
"url": "https://example-shop.com/terms",
"content": "# Terms and Conditions\n\n..."
},
"faq": {
"url": "https://example-shop.com/faq",
"content": "# FAQ\n\n..."
}
}
}
If a page type is not found, it will be null:
{
"faq": null
}
GET /api/jobs
Authorization: Bearer <your-api-key>
Example:
curl http://localhost:3000/api/jobs \
-H "Authorization: Bearer your-secret-key-here"
Configuration is done via environment variables:
API_KEY: Pre-shared key for Bearer authentication (required)PORT: HTTP server port (default: 3000)MAX_CONCURRENT_JOBS: Maximum number of concurrent scraping jobs (default: 3)To remove the service and all files:
sudo ./scripts/uninstall.sh
npm run dev
npm run build
npm run watch
All logs are written to stdout/stderr and can be viewed using journalctl:
# Follow logs
sudo journalctl -u webshop-scraper -f
# View logs from today
sudo journalctl -u webshop-scraper --since today
# View last 100 lines
sudo journalctl -u webshop-scraper -n 100
ISC