Botright 项目安装与使用教程
1. 项目目录结构及介绍
Botright 项目的目录结构如下:
Botright/
├── botright/
│ ├── __init__.py
│ ├── core.py
│ ├── utils.py
│ └── ...
├── docs/
│ ├── index.rst
│ ├── ...
├── tests/
│ ├── test_core.py
│ ├── ...
├── .flake8
├── .gitignore
├── LICENSE
├── README.md
├── pyproject.toml
├── requirements-test.txt
├── requirements.txt
├── setup.cfg
└── ...
目录结构介绍
botright/
: 包含项目的主要代码文件,如核心功能实现、工具函数等。docs/
: 包含项目的文档文件,如index.rst
等。tests/
: 包含项目的测试代码文件,用于测试核心功能的正确性。.flake8
: 配置文件,用于代码风格检查。.gitignore
: Git 忽略文件配置。LICENSE
: 项目许可证文件。README.md
: 项目介绍和使用说明。pyproject.toml
: 项目配置文件,包含项目依赖、构建工具等信息。requirements-test.txt
: 测试环境依赖文件。requirements.txt
: 项目运行依赖文件。setup.cfg
: 项目打包和分发配置文件。
2. 项目启动文件介绍
Botright 项目的启动文件通常是 botright/core.py
或 botright/__init__.py
。这些文件包含了项目的核心逻辑和初始化代码。
示例启动代码
import asyncio
import botright
async def main():
botright_client = await botright.Botright()
browser = await botright_client.new_browser()
page = await browser.new_page()
await page.goto("https://google.com")
await botright_client.close()
if __name__ == "__main__":
asyncio.run(main())
启动文件功能
botright.Botright()
: 初始化 Botright 客户端。new_browser()
: 创建一个新的浏览器实例。new_page()
: 在浏览器中创建一个新的页面。goto()
: 导航到指定的 URL。close()
: 关闭 Botright 客户端。
3. 项目的配置文件介绍
Botright 项目的配置文件主要包括 pyproject.toml
和 setup.cfg
。
pyproject.toml
pyproject.toml
文件用于配置项目的构建工具、依赖项等信息。
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "botright"
version = "0.5.1"
description = "Botright, the most advance undetected, fingerprint-changing, captcha-solving, open-source automation framework."
authors = [
{ name="Vinyzu" }
]
dependencies = [
"playwright",
"hcaptcha-challenger",
"recaptcha-challenger",
"geetest-challenger"
]
setup.cfg
setup.cfg
文件用于配置项目的打包和分发信息。
[metadata]
name = botright
version = 0.5.1
description = Botright, the most advance undetected, fingerprint-changing, captcha-solving, open-source automation framework.
author = Vinyzu
license = GPL-3.0
[options]
packages = find:
install_requires =
playwright
hcaptcha-challenger
recaptcha-challenger
geetest-challenger
[options.package_data]
* = *.py, *.rst
配置文件功能
pyproject.toml
: 定义项目的构建系统和依赖项。setup.cfg
: 配置项目的打包和分发选项,如包名、版本、依赖项等。
通过以上配置文件,可以确保项目在不同环境中的一致性和可重复性。