File size: 2,167 Bytes
a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b 96a28db a65fe1b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | ---
title: Asset Extractor API
emoji: 🐍
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
app_port: 7860
---
# Asset Extractor API
FastAPI service that extracts assets from any URL, grouped by type:
**image · video · audio · svg/icon · font**.
## Usage
### `POST /assets`
Give it a URL, get back the page's assets grouped by category.
```bash
curl -X POST https://lljz66-api.hf.space/assets \
-H 'Content-Type: application/json' \
-d '{"url": "https://example.com"}'
```
```json
{
"url": "https://example.com",
"title": "Example Domain",
"total": 3,
"assets": {
"image": ["https://example.com/logo.png"],
"video": [],
"audio": [],
"svg_icon": ["https://example.com/favicon.ico"],
"font": ["https://fonts.gstatic.com/..."]
}
}
```
### Request fields
| field | type | default | meaning |
|-------|------|---------|---------|
| `url` | string | — | page to extract from (required) |
| `include_data_uris` | bool | `false` | keep `data:` URIs |
| `groups` | list[string] | all | subset: `image`, `video`, `audio`, `svg_icon`, `font` |
### Response fields
| field | type | meaning |
|-------|------|---------|
| `url` | string | final URL after redirects |
| `title` | string \| null | page title |
| `total` | int | total asset count |
| `assets` | object | grouped asset URL lists |
> Static HTML only — JS-rendered assets are not captured.
## Structure (monolith-modular)
```
app/
├── main.py # FastAPI app assembly
├── config.py # settings (fetch limits, SSRF block-list)
├── schemas.py # pydantic request/response models
├── routers/
│ └── assets.py # POST /assets (HTTP layer)
└── services/
├── fetcher.py # safe async page fetch (SSRF/size/timeout guards)
├── resolver.py # absolutize asset references
├── asset_service.py # orchestrator: fetch -> parse -> extract -> group
└── extractors/ # images, videos, audios, icons_svg, fonts
```
## Local dev
```bash
pip install -r requirements.txt
uvicorn app.main:app --reload --port 7860
```
|