재사용 가능한 안티탐지 브라우저 드라이버 + 라이브 콘솔/응답캡처 + 알림 채널 추상화
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file browser_kit-0.2.0.tar.gz.
File metadata
- Download URL: browser_kit-0.2.0.tar.gz
- Upload date:
- Size: 19.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67cc07270f9e9adf17c478ac7e7d8bee92f14b712576a7312cbb7496270e5608
|
|
| MD5 |
929d030902ffd074e3c8c7e1d4e83981
|
|
| BLAKE2b-256 |
b999357174f5c1f146430100c835f3afe6767307b08c7485c53c2b8bedbfbdff
|
File details
Details for the file browser_kit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: browser_kit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 26.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb6e2f07ac4b5f80e405f27f77be85e92f271349ad765424f04fc6bc9c627fa7
|
|
| MD5 |
0ffc93385170ca39ccfeb72ecc916125
|
|
| BLAKE2b-256 |
64b57fce0479e437d32e64c8cb5d56235f4032e08700ee33f4b90144e23f31d5
|