Metadata-Version: 2.3
Name: qchancrawler
Version: 0.1.0
Summary: Crawl posts from QQ channels to text files
Author: Ivy Xu
Author-email: Ivy Xu <ivyxu1337@gmail.com>
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: httpx
Requires-Dist: anyio
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# QChanCrawler

QChanCrawler is a command-line tool that retrieves posts from a QQ
channel and saves them to a text file.

## Requirements

- Python 3.10 or later.
- An exported browser cookie file in the Mozilla/Netscape `cookies.txt` format.

## Installation

```console
pip install qchancrawler
```

## Usage

```console
qchancrawler [-h] -g ID -c PATH [-o PATH] [-p NUM]
```

For example, start at page 5 and write posts to `posts.txt`:

```console
qchancrawler -g 012345 -c ./cookies.txt -o posts.txt -p 5
```

The package can also be invoked as a module:

```console
python -m qchancrawler -g 012345 -c ./cookies.txt
```

Options:

- `-g`, `--guild`: QQ channel/guild ID to crawl.
- `-c`, `--cookie`: Path to the exported QQ cookie file.
- `-o`, `--outfile`: Output file or existing directory. If omitted, the output
  file defaults to `./<guild-id>.txt`. When an existing directory is supplied,
  `<guild-id>.txt` is created inside it.
- `-p`, `--page`: Page number from which to start crawling. Defaults to `1`.

## Output

Existing output files are preserved and new entries are appended.

Each exported post is written on its own line in this format:

```text
<author>: <text> <post-id>
```

A guild ID and a post ID can be used to view a specific post:

`https://pd.qq.com/g/<guild-id>/post/<post-id>`

## Cookie file

The cookie file must use the Mozilla/Netscape `cookies.txt` format.
Browser extensions and other cookie-export tools can create files in this
format.

Cookie files contain sensitive authentication data. Do not commit, publish, or
share them.

## Disclaimer

Use QChanCrawler only for channels and data you are authorized to access.
Protect personal data and exported cookies, avoid excessive requests, respect
service rate limits, and comply with QQ's terms and policies.
