Skip to main content

재사용 가능한 안티탐지 브라우저 드라이버 + 인터랙티브 REPL + 알림 채널 추상화

Project description

browser_kit

재사용 가능한 안티탐지 브라우저 드라이버 + 인터랙티브 REPL + 알림 채널 추상화. 특정 사이트/프로젝트에 종속되지 않은, 스크래핑 공통 인프라만 모아둔 패키지다.

구성

모듈 내용
browser_kit.driver rebrowser-playwright 기반 anti-detection 브라우저, 세션(.userdata) 유지, js_repl/py_repl 인터랙티브 셸
browser_kit.notify Notifier 채널 추상화(텔레그램 구현 포함) + 인메모리 1:N pub/sub Broadcaster

캡차 풀이처럼 구체적인 로직은 의도적으로 제외했다. 이 패키지는 "어디서든 재활용 가능한 기반"만 담는다.

설치

# 드라이버만
pip install "git+ssh://git@github.com/<you>/browser_kit.git"

# 텔레그램 알림 채널까지
pip install "git+ssh://git@github.com/<you>/browser_kit.git#egg=browser_kit[telegram]"

로컬 개발 시 (uv 프로젝트에서 editable path 의존성):

# 소비 프로젝트의 pyproject.toml
dependencies = ["browser_kit"]

[tool.uv.sources]
browser_kit = { path = "../browser_kit", editable = true }

사용

드라이버 + REPL

from browser_kit.driver import open_page, js_repl

async with open_page() as page:          # 세션 유지 anti-detection 브라우저
    await page.goto("https://example.com")
    await js_repl(page)                   # js> 프롬프트로 즉석 평가

IPython 등 async 터미널:

from browser_kit.driver import start, stop
page = await start("https://example.com")
...
await stop()

알림 채널 (추상화)

from browser_kit.notify import TelegramNotifier, NullNotifier, Notifier

notifier: Notifier = TelegramNotifier.from_env()   # 토큰 없으면 NullNotifier 로 교체해도 동일 호출
await notifier.send_message("작업 시작")
answer = await notifier.wait_reply(timeout=300)     # 발신 전용 채널이면 None

새 채널(메일/문자)을 추가하려면 Notifier 를 구현하면 된다 — 호출부는 그대로.

이벤트 브로드캐스터 (SSE 등 fan-out)

from browser_kit.notify import Broadcaster

bus = Broadcaster(log_formatter=lambda e: f"[{e['type']}] {e.get('text','')}")
q = bus.subscribe()
bus.publish({"type": "message", "text": "hello"})

환경변수

변수 의미 기본값
BROWSER_KIT_USER_DATA_DIR 세션(쿠키·캡차 통과) 저장 경로 ./.userdata
SCRAPER_HEADLESS 1이면 헤드리스 (headful)
SCRAPER_BROWSER_CHANNEL 브라우저 채널(빈 값=번들 크로미움) chrome
SCRAPER_PROXY_SERVER / _USERNAME / _PASSWORD 프록시 (미사용)
TELEGRAM_BOT_TOKEN / TELEGRAM_CHAT_ID TelegramNotifier.from_env()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

browser_kit-0.1.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

browser_kit-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file browser_kit-0.1.0.tar.gz.

File metadata

  • Download URL: browser_kit-0.1.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for browser_kit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a4cade14228801bac4862cb29639ef2cbeeafb5030f7fd33a5024bf2995cbed
MD5 0fd0ac88818976326eab60ae342daa19
BLAKE2b-256 c2cccd57c0172ddc6429b6409b4d7138c5d96f6230ea72c6bda9ca54e2641780

See more details on using hashes here.

File details

Details for the file browser_kit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: browser_kit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for browser_kit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87d7165420de21a7de2831e2a23914117faaac3214890f0a52ee234313d47bb6
MD5 0d9fdaa948bb1836cf2ae35e1ab33a7e
BLAKE2b-256 99e38800a39a952e3b3d25d1092529c9f278ae4c2ce1462af515b3ca625c8295

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page