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() 용 |
— |
Metadata
Release files for browser_kit 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| browser_kit-0.2.0.tar.gz | 19.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| browser_kit-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.1 kB
Release files / browser_kit-0.2.0.tar.gz
| Download URL | browser_kit-0.2.0.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67cc07270f9e9adf17c478ac7e7d8bee92f14b712576a7312cbb7496270e5608
|
|
BLAKE2b-256 checksum How to use checksums |
b999357174f5c1f146430100c835f3afe6767307b08c7485c53c2b8bedbfbdff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / browser_kit-0.2.0-py3-none-any.whl
| Download URL | browser_kit-0.2.0-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb6e2f07ac4b5f80e405f27f77be85e92f271349ad765424f04fc6bc9c627fa7
|
|
BLAKE2b-256 checksum How to use checksums |
64b57fce0479e437d32e64c8cb5d56235f4032e08700ee33f4b90144e23f31d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|