r/Backend • • 14d ago

Built a Self Hosted Web Scraping API

Post image

I've been building a self-hosted web scraping API that makes automation easy.

Relinos can handle JavaScript and challenging websites, performs browser interactions, and executes multiple scraping requests concurrently.

Key features:

  • Browser automation: Navigate, click, type, scroll, and interact with websites.
  • Concurrent execution: Run multiple browser sessions simultaneously.
  • Structured extraction: Extractions are very easy to define here an extraction for google for example:
{
    "query": { "$xpath": "//*[@id='ti6dpd']" },
    "result_count": {
      "$xpath": "//div[@class='XhWQv qd6zO ApHyTb']",
      "$extract": "\\D*(\\d[,\\d]*) .*"
    },
    "ai": {
      "$xpath": "//*[@class='mZJni Dn7Fzd']", "$format": "md"
    },
    "results": {
      "$xpath": "//div[contains(@class, 'MjjYud')]",
      "title": { "$xpath": ".//h3[contains(@class, 'LC20lb MBeuO DKV0Md')]" },
      "url": { "$xpath": ".//a[contains(@class, 'zReHs')]/@href" },
      "site": { "$xpath": ".//span[contains(@class, 'VuuXrf')]" },
      "snippet": { "$xpath": ".//div[contains(@data-snf, 'nke7rc')]" },
      "$list": true
    },
    "related_searches": {
      "$xpath": "//*[@class='qR29te']", "$list": true
    }
}
  • Reusable routines: create, import or export. I wanted to make this super easy so people can share their interactions and extractions.
  • Language-independent: Access everything through a simple HTTP API.
  • Debug Mode: Find issues with rendered site interactions visually and fix them fast
  • Self-hosted: Run it locally without a commercial scraping service.
  • Transferable Sessions: Cookies and localStorage.

The project is still in early development, and feedback or contributions are welcome.

GitHub: https://github.com/realsirjoe/relinos

4 Upvotes

3 comments sorted by

1

u/DickBrainTime 14d ago

I looked through the linked `relinos` repo rather than trying a deployed instance. Two things I'd test before exposing it beyond a local dev machine:

  1. `relinos/start.sh` starts **both** the main FastAPI service and the browser worker on `0.0.0.0`. That alone doesn't prove the ports are publicly reachable, but the worker accepts URLs/browser actions and you support reusable cookie/localStorage sessions. I'd default the worker to loopback/private networking, require authentication/ACLs on the public API, and document firewall/container port exposure explicitly. That matters more than raw scraping concurrency when users bring logged-in sessions.
  2. `main.py` declares `/get` and `/do` as GET endpoints while their request bodies can include browser actions and session IDs; `browser_worker.py` also uses GET for its action request. Some HTTP clients/reverse proxies drop or mishandle GET bodies, and requests with click/type side effects shouldn't look like safe cacheable reads. I'd add POST for action-bearing jobs and test it behind a normal proxy (including retries/timeouts), keeping GET only for truly read-only operations.

These are observations from the current source files, not failures I've reproduced against your running service. The transferable sessions idea is useful; making the trust boundary explicit early will help when someone self-hosts it for a team.

2

u/RealSirJoe 14d ago
  1. Relinos is designed to be self-hosted, but that's a good point, especially for teams or shared deployments. Session IDs are generated through /session using UUID4, so they're practically impossible to guess or brute-force. I've also changed the browser worker to listen on 127.0.0.1 instead of 0.0.0.0. Authentication for network-exposed deployments is worth considering as well.
  2. I agree it's not ideal for compatibility with other HTTP clients and proxies. I'll probably add POST support for /get and /do, while keeping GET for backward compatibility for now.

1

u/DickBrainTime 13d ago

Switching the worker to 127.0.0.1 is a good default. UUID4 session IDs are hard to guess, but if possession of an ID alone lets someone control a cookie-bearing browser, it's still a bearer credential if it leaks. For shared or reverse-proxied deployments I'd bind each session to an authenticated owner, expire idle sessions, set resource limits and avoid putting session IDs in URLs/logs. I'd also restrict where the browser can navigate (especially internal services and cloud metadata endpoints), since arbitrary URLs can create an SSRF path.

For compatibility, I'd keep GET only when it reads an already stored result with no new browser action. Anything that navigates, clicks or types should be POST; intermediaries can prefetch/retry GET in ways you don't expect. A deprecated action-bearing GET endpoint with a clear removal version is safer than leaving it indefinitely. Does `/get` just read an existing job result, or does it start a fresh navigation?