# Baidu Tieba 贴吧 Scraper (`parsebird/baidu-tieba-scraper`) Actor

Scrape Baidu Tieba 百度贴吧 posts, comments and replies from keyword search, forum tabs, hot topics, user profiles and post links. Get text, images, videos, views, likes, author level, IP region and forum data. No login. Export JSON, CSV, Excel or use the API.

- **URL**: https://apify.com/parsebird/baidu-tieba-scraper.md
- **Developed by:** [ParseBird](https://apify.com/parsebird) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.99 / 1,000 posts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### Baidu Tieba 贴吧 Scraper

**Baidu Tieba Scraper** extracts public posts, comments and replies from [Baidu Tieba (百度贴吧)](https://tieba.baidu.com/), China's largest forum community. Search Tieba by keyword, scrape forum (吧) tabs, hot topics (话题) and user profiles, or paste post links. Each post comes back with its text, images, video, views, replies, likes, saves, shares, author and forum data. Comments come with the author's level, gender and IP region. You don't need a Baidu account, a cookie or an API key.

<table><tr>
<td style="border-left:4px solid #1C1917;padding:12px 16px;font-weight:600">
One row per Tieba post (30+ fields) and, if you want them, one row per comment (楼层) and reply (楼中楼), from keyword search, forum tabs, hot topics, user profiles or post links.
</td>
</tr></table>

##### Copy to your AI assistant

Copy this block into ChatGPT, Claude, Cursor, or any LLM to start using this actor.

```
Apify Actor: parsebird/baidu-tieba-scraper. Scrapes public Baidu Tieba (tieba.baidu.com, 百度贴吧) posts, comments and replies without login. Call via ApifyClient: client.actor("parsebird/baidu-tieba-scraper").call(run_input={"searchTerms": ["AI"], "sortSearchBy": "latest", "maxPosts": 50}). Inputs (combine any): searchTerms (string[]: keywords, one search each), sortSearchBy ("most_relevant" | "latest" | "oldest", default "most_relevant"), searchWithinForum (string: forum name, ID or https://tieba.baidu.com/f?kw= URL to search inside one forum), forums (object[]: {forum: name | ID | URL, tabs: ["highlights" | "popular" | "latest" | "video"], customTabs: string[] of the forum's own Chinese tab names, maxPostsPerTab: integer}), urls ({url}[]: post URLs https://tieba.baidu.com/p/<id>, profile URLs https://tieba.baidu.com/home/main?id=tb.1.… or ?un=<name>, hot topic URLs https://tieba.baidu.com/hottopic/browse/hottopic?topic_id=…, forum URLs /f?kw=…), topics (string[]: topic names like 剧情 or #剧情), sortTopicPostsBy ("hottest" | "latest"), maxCommentsPerPost (integer, default 0), maxRepliesPerComment (integer, default 0), sortCommentsBy ("popular" | "latest" | "oldest", default "latest"), maxPosts (integer, default 50, 0 = no limit: per search term, topic, profile or forum link), proxyConfiguration (optional). Output: dataset rows with type "post" (postId, threadId, url, title, content, images[{width,height,smallPic,waterPic,bigPic}], videoInfo{playUrl,playCount,duration,thumbnailUrl,height,width}, authorName, authorId, authorIsVerified, authorLevel, authorAvatarUrl, ipAddress, createTime (s), createTimeUtc, viewCount, commentCount, collectCount, shareCount, agreeCount, disagreeCount, diffAgreeCount, validPostCount, forumId, forumName, forumAvatarUrl, forumPrimaryCategory, forumSecondaryCategory, sourceType, sourceValue, forumTab) or type "comment" (commentId, threadId, postUrl, floor, content, images[], mentions[{name,id}], createTime (ms), createTimeUtc, agreeCount, disagreeCount, diffAgreeCount, replyCount, authorId, authorName, authorNameShow, authorAvatarUrl, authorLevel, authorLevelInForum, authorLevelName, authorIsVerified, authorGender, ipAddress, replyToCommentId). Pricing: pay per post and per comment saved. Full API spec: https://apify.com/parsebird/baidu-tieba-scraper/api. Get your token: https://console.apify.com/settings/integrations.
```

### What is Baidu Tieba Scraper?

**Baidu Tieba Scraper** turns Tieba threads into structured data. Enter a keyword, a forum or a link and click **Start**. You get clean rows of Tieba data: post titles and full first-floor text, image links in three sizes, video files, view and reply counts, likes and dislikes, plus the forum's name and category. Turn on comments to get each floor and its replies with the author's level and IP region. Download the results as **JSON, CSV or Excel**, or read them through the API.

It works as a **Baidu Tieba API alternative**. Baidu has no public data API for Tieba, so the Actor reads the same public data the Tieba app shows a logged-out visitor. You never have to sign in or scan a QR code.

### What can Baidu Tieba Scraper do?

- 🔍 **Search Tieba by keyword.** Search all of Tieba, or one forum only, and sort by most relevant, latest or oldest.
- 🗂️ **Scrape forum tabs.** Pick 精品 highlights, 热门 popular, 最新 latest and 视频 video tabs, or any of the forum's own tabs (like 影视评论 in 电影吧) by their Chinese name.
- \#️⃣ **Scrape hot topics.** Enter a topic name such as `剧情` or paste a hot topic link, sorted by hottest or latest.
- 👤 **Scrape user profiles.** Paste a profile link to get the threads that user started.
- 🔗 **Scrape single posts.** Paste post links to get the post and, if you want, its comments.
- 💬 **Scrape comments and replies.** Set how many floors per post and how many 楼中楼 replies per floor, sorted by popular, latest or oldest.
- 📅 **Schedule and monitor.** Re-run a search or forum tab every day with [Apify Schedules](https://docs.apify.com/platform/schedules) to catch new threads.
- 🔌 **API and integrations.** Use the [Apify API](https://docs.apify.com/api/v2), or send results to Google Sheets, Zapier, Make, Slack or webhooks with [Apify integrations](https://docs.apify.com/platform/integrations). Export as JSON, CSV, Excel, XML or HTML.

### What data can you extract from Baidu Tieba?

**Posts** (`type: "post"`)

| Field | Description |
|-------|-------------|
| `postId` · `threadId` · `url` | ID of the first floor, thread ID and the `tieba.baidu.com/p/…` link |
| `title` · `content` | Thread title and the full text of the first floor (emoji shown as `[笑眼]`) |
| `images` | Each image with `width`, `height` and three sizes: `smallPic` (720 px), `waterPic` (960 px) and `bigPic` (original) |
| `videoInfo` | `playUrl` (MP4), `playCount`, `duration` (s), `thumbnailUrl`, `width`, `height`. `null` when the post has no video |
| `authorName` · `authorId` · `authorLevel` · `authorIsVerified` · `authorAvatarUrl` | The poster. `authorLevel` is their level in this forum |
| `ipAddress` | The poster's IP region as Tieba shows it, for example `广东` |
| `createTime` · `createTimeUtc` | Post time as a Unix timestamp in seconds, and as ISO 8601 in UTC |
| `viewCount` · `commentCount` · `validPostCount` | Views, Tieba's reply count, and the number of floors still visible |
| `agreeCount` · `disagreeCount` · `diffAgreeCount` | Likes, dislikes and likes minus dislikes |
| `collectCount` · `shareCount` | Saves (收藏) and shares |
| `forumId` · `forumName` · `forumAvatarUrl` · `forumPrimaryCategory` · `forumSecondaryCategory` | The forum (吧) and Tieba's two category levels, for example `影视综` / `影视话题` |
| `sourceType` · `sourceValue` · `forumTab` | Which of your inputs found the post |

**Comments and replies** (`type: "comment"`)

| Field | Description |
|-------|-------------|
| `commentId` · `threadId` · `postUrl` · `floor` | Comment ID, its thread and the floor number (楼层). Replies have no floor |
| `content` · `images` · `mentions` | Comment text, image links and @mentions as `{name, id}` |
| `createTime` · `createTimeUtc` | Comment time as a Unix timestamp in milliseconds, and as ISO 8601 in UTC |
| `agreeCount` · `disagreeCount` · `diffAgreeCount` · `replyCount` | Likes, dislikes, the difference, and the number of 楼中楼 replies |
| `authorName` · `authorNameShow` · `authorAvatarUrl` · `authorId` | The commenter's username, display name, avatar and ID |
| `authorLevel` · `authorLevelInForum` · `authorLevelName` | Tieba account level, level in this forum and the forum's name for that level, for example `银幕巨人` |
| `authorGender` · `authorIsVerified` · `ipAddress` | `male`, `female` or `null`, verification flag and IP region |
| `replyToCommentId` | For replies: the floor (comment) they belong to. `null` for floors |

### How to scrape Baidu Tieba

1. Open [Baidu Tieba Scraper](https://apify.com/parsebird/baidu-tieba-scraper) on Apify Store and click **Try for free**.
2. Fill in one or more inputs: **Search terms**, **Forums**, **Direct URLs** or **Topics**. You can mix them in one run.
3. To get comments, set **Max comments per post** and, for replies, **Max replies per comment**.
4. Set **Max posts** for each search term, topic, profile or forum link.
5. Click **Start**. When the run finishes, open the **Output** tab. The **Posts** and **Comments** views split the two row types. Download your Tieba data as JSON, CSV, Excel, XML or HTML, or read it through the API.

### Input parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `searchTerms` | string\[] | — | Keywords to search. Each keyword is a separate search |
| `sortSearchBy` | string | `most_relevant` | `most_relevant`, `latest` or `oldest` |
| `searchWithinForum` | string | — | Forum name, ID or URL to search inside. Empty = all of Tieba |
| `forums` | object\[] | — | `{forum, tabs, customTabs, maxPostsPerTab}`. `tabs`: `highlights`, `popular`, `latest`, `video`. `customTabs`: the forum's own tab names in Chinese, exactly as shown. Without tabs, `latest` is used |
| `urls` | object\[] | — | Post, user profile, hot topic and forum links |
| `topics` | string\[] | — | Hot topic names, with or without `#` |
| `sortTopicPostsBy` | string | `hottest` | `hottest` or `latest`, for topics and hot topic links |
| `maxCommentsPerPost` | integer | `0` | Floors to save per post. `0` = no comments |
| `maxRepliesPerComment` | integer | `0` | 楼中楼 replies to save per floor. `0` = no replies |
| `sortCommentsBy` | string | `latest` | `popular`, `latest` or `oldest` |
| `maxPosts` | integer | `50` | Posts per search term, topic, profile or forum link. `0` = no limit |
| `proxyConfiguration` | object | — | Optional. Not needed for normal use |

**Example inputs**

Search two keywords, newest first:

```json
{ "searchTerms": ["AI", "电视剧"], "sortSearchBy": "latest", "maxPosts": 50 }
```

Scrape the highlights and latest tabs of 科技吧, and the custom 影视评论 tab of 电影吧:

```json
{
    "forums": [
        { "forum": "科技吧", "tabs": ["highlights", "latest"], "maxPostsPerTab": 30 },
        { "forum": "https://tieba.baidu.com/f?kw=电影", "customTabs": ["影视评论"], "maxPostsPerTab": 30 }
    ]
}
```

Scrape the newest posts of a hot topic:

```json
{ "topics": ["剧情"], "sortTopicPostsBy": "latest", "maxPosts": 50 }
```

Scrape a post with 20 floors and up to 10 replies each:

```json
{
    "urls": [{ "url": "https://tieba.baidu.com/p/10860925843" }],
    "maxCommentsPerPost": 20,
    "maxRepliesPerComment": 10
}
```

### Output example

A post (image URLs shortened):

```json
{
    "postId": 153712361553,
    "type": "post",
    "url": "https://tieba.baidu.com/p/10860925843",
    "threadId": 10860925843,
    "title": "被《功夫女足》片尾彩蛋搞泪目了！",
    "authorName": "看雪不玩雪",
    "authorId": 4090775523,
    "authorIsVerified": false,
    "authorLevel": 5,
    "authorAvatarUrl": "https://gss0.bdstatic.com/6LZ1dD3d1sgCo2Kml5_Y_D3/sys/portrait/item/tb.1.5b48a8ad.K37H3d0FFqmwSw03QJcC9Q?t=1793884649",
    "content": "星爷虽然全程没出镜，但片尾字幕时，他和林子聪以背影现身，完美复刻了《少林足球》的经典造型！……",
    "images": [
        {
            "width": 560,
            "height": 247,
            "smallPic": "https://tiebapic.baidu.com/forum/w%3D720%3Bq%3D60%3Bg%3D0/sign=…/fddeb48f8c5494ee263d511b6bf5e0fe99257e91.jpg?tbpicau=…",
            "waterPic": "https://tiebapic.baidu.com/forum/w%3D960%3Bq%3D100/sign=…/fddeb48f8c5494ee263d511b6bf5e0fe99257e91.jpg?tbpicau=…",
            "bigPic": "https://tiebapic.baidu.com/forum/pic/item/fddeb48f8c5494ee263d511b6bf5e0fe99257e91.jpg?tbpicau=…"
        }
    ],
    "videoInfo": null,
    "createTime": 1783779579,
    "createTimeUtc": "2026-07-11T14:19:39.000Z",
    "viewCount": 76185,
    "commentCount": 103,
    "collectCount": 10,
    "shareCount": 1,
    "agreeCount": 349,
    "disagreeCount": 21,
    "diffAgreeCount": 328,
    "validPostCount": 46,
    "forumId": 14,
    "forumName": "电影",
    "forumAvatarUrl": "https://tiebapic.baidu.com/forum/w%3D120%3Bh%3D120/sign=…/0824ab18972bd407babbddbf6c899e510fb30977.jpg?tbpicau=…",
    "forumPrimaryCategory": "影视综",
    "forumSecondaryCategory": "影视话题",
    "ipAddress": "广东",
    "sourceType": "url",
    "sourceValue": "https://tieba.baidu.com/p/10860925843?fr=frs",
    "scrapedAt": "2026-11-05T13:17:31Z"
}
```

A reply (楼中楼) under floor `153717143852`:

```json
{
    "type": "comment",
    "commentId": 153734339766,
    "threadId": 10860925843,
    "postUrl": "https://tieba.baidu.com/p/10860925843",
    "floor": null,
    "authorId": 3105949402,
    "images": [],
    "mentions": [],
    "content": "***等不到",
    "createTime": 1784345649000,
    "createTimeUtc": "2026-07-18T03:34:09.000Z",
    "agreeCount": 0,
    "disagreeCount": 0,
    "diffAgreeCount": 0,
    "replyCount": 0,
    "authorName": null,
    "authorNameShow": "我爱福宝FB",
    "authorAvatarUrl": "https://himg.bdimg.com/sys/portrait/item/tb.1.1e004e71.1FXG1i0F_PCwxR799P-cLA?t=1793884651",
    "authorLevel": null,
    "authorLevelInForum": 1,
    "authorIsVerified": false,
    "authorGender": null,
    "authorLevelName": "群众演员",
    "ipAddress": null,
    "replyToCommentId": 153717143852,
    "scrapedAt": "2026-11-05T13:17:31Z"
}
```

### How much does it cost to scrape Baidu Tieba?

Baidu Tieba Scraper uses **pay-per-event** pricing. You pay for each post and each comment or reply saved to your dataset. Compute and proxy costs are included in the price. Deleted posts, invalid links and duplicates are free.

| Event | Free | Bronze | Silver | Gold |
|-------|------|--------|--------|------|
| Post (per 1,000) | $2.99 | $2.49 | $2.29 | $1.99 |
| Comment or reply (per 1,000) | $1.79 | $1.49 | $1.29 | $0.99 |

For example, on the Free plan 100 posts cost about $0.30. The same 100 posts with 10 comments each (1,000 comments) cost about $0.30 + $1.79 = $2.09. Use **Max posts**, **Max comments per post** or a maximum cost per run in Apify Console to cap a run. The Actor stops cleanly when it reaches any of these limits.

### Use the Baidu Tieba API from Python or JavaScript

Get your API token from [Apify Console](https://console.apify.com/settings/integrations), then call the Actor with the [Apify API client for Python](https://docs.apify.com/api/client/python) or [for JavaScript](https://docs.apify.com/api/client/js).

**Python**

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")

run = client.actor("parsebird/baidu-tieba-scraper").call(run_input={
    "searchTerms": ["电视剧"],
    "sortSearchBy": "latest",
    "maxPosts": 50,
    "maxCommentsPerPost": 10,
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    if item["type"] == "post":
        print(item["forumName"], item["title"], item["viewCount"])
```

**JavaScript**

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });

const run = await client.actor('parsebird/baidu-tieba-scraper').call({
    forums: [{ forum: '科技吧', tabs: ['latest'], maxPostsPerTab: 30 }],
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((p) => `${p.createTimeUtc} ${p.title}`));
```

The full endpoint reference, including synchronous runs that return the dataset in one call, is on the [API tab](https://apify.com/parsebird/baidu-tieba-scraper/api).

### Use cases

- **Public opinion monitoring.** Track what Tieba users say about a brand, product, show or game, with dates and IP regions.
- **Fan and community research.** Follow a forum's latest and highlighted threads to see which topics take off.
- **Content and trend analysis.** Compare views, replies and likes across threads, tabs and hot topics.
- **Chinese-language NLP.** Build corpora of forum posts and conversations with replies and @mentions.
- **Competitor and market research.** Collect user questions and complaints from product and industry forums.

### How it works

1. Each input becomes a list of threads: search results, a forum tab, a hot topic, a user's threads or a single post.
2. Each thread is opened through Tieba's public app data, which gives the full first floor, counts, author and forum details.
3. If you asked for comments, the Actor reads the thread's floors in the order you chose, then each floor's 楼中楼 replies.
4. Rows are saved and charged as they come in. A post found by two inputs is saved once. A run that Apify moves to another server resumes without duplicates.

### FAQ

**Do I need a Baidu account, cookie or API key?**
No. The Actor reads public Tieba data the way a logged-out visitor sees it.

**How does "popular" comment sorting work?**
Tieba doesn't publish a hot ranking of floors to logged-out visitors. With `popular`, the Actor reads up to the first 300 floors of a thread (at least 3× your comment limit) and returns the most-liked ones first. `latest` starts from the newest floor and `oldest` follows the thread from the top.

**Which tabs can I use with `customTabs`?**
Any tab the forum shows, written exactly as on Tieba, for example `影视评论` or `吧友互助` in 电影吧. If a name doesn't match, the log lists the forum's real tab names. `热门`, `最新`, `精品` and `视频` also work there.

**Why is `ipAddress` or `authorLevel` empty on some comments?**
Tieba doesn't return the IP region or account level for 楼中楼 replies, so those fields are `null` on replies. The forum level (`authorLevelInForum`) is still there.

**What's the difference between `commentCount` and `validPostCount`?**
`commentCount` is Tieba's own reply count, which also counts 楼中楼 replies. `validPostCount` is the number of floors still visible in the thread.

**Why does some comment text contain `***`?**
Tieba masks some words itself. The Actor returns the text exactly as Tieba serves it.

**A post appears in two of my forum tabs. Why do I get it only once?**
Each post is saved and charged once per run, even when several inputs find it. The row records the first input that found it.

**Which profile links work?**
`https://tieba.baidu.com/home/main?id=tb.1.…` links (the `id` is the user's portrait ID) and `https://tieba.baidu.com/home/main?un=<username>` links. The Actor returns the threads the user started.

**Can I download videos and images?**
Yes. `videoInfo.playUrl` is a direct MP4 link and `bigPic` is the original image. Tieba signs these links, so download the files soon after the run.

**Why did an input return nothing?**
The post or user was deleted or hidden, the forum or topic doesn't exist, or the link is wrong. The log lists it as "not found", and it isn't charged.

**Can I schedule recurring runs?**
Yes. Use [Apify Schedules](https://docs.apify.com/platform/schedules) to run hourly, daily or weekly.

**Can I use it with Make, Zapier, Google Sheets or an AI agent?**
Yes, through [Apify integrations](https://docs.apify.com/platform/integrations) and the [Apify API](https://docs.apify.com/api/v2). The Actor is also available to AI agents through the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp).

**Something doesn't work. What should I do?**
Open an issue on the [Issues tab](https://apify.com/parsebird/baidu-tieba-scraper/issues) with your run link. We read every report.

### Is it legal to scrape Baidu Tieba?

This Actor only collects publicly available data that any logged-out visitor can see on Tieba. It doesn't log in or access private content. Posts and comments can still include personal data, such as usernames and IP regions, which is protected by laws such as China's Personal Information Protection Law (PIPL) and the EU's GDPR. Don't scrape personal data unless you have a legitimate reason, and check Baidu's terms of service before you use the data. Posts are copyrighted by their authors, so get permission before you republish them. If you're unsure, consult a lawyer. Read more in Apify's guide: [Is web scraping legal?](https://blog.apify.com/is-web-scraping-legal/)

### Related Actors

| Actor | What it does |
|-------|--------------|
| [Baidu 百度 Search Scraper](https://apify.com/parsebird/baidu-search-scraper) | Baidu search results for any keyword, with Baidu's AI answer, news, videos and the 百度热搜 hot list |
| [Toutiao 头条 Scraper](https://apify.com/parsebird/toutiao-scraper) | Toutiao articles, videos and 微头条 posts from links or whole profiles |
| [Bilibili 哔哩哔哩 Scraper](https://apify.com/parsebird/bilibili-scraper) | Bilibili videos, comments, danmaku and UP主 profiles |
| [Kuaishou 快手 Scraper](https://apify.com/parsebird/kuaishou-scraper) | Kuaishou videos with MP4 links, music and creator stats |
| [Sogou WeChat Article Search Scraper](https://apify.com/parsebird/sogou-wechat-search-scraper) | WeChat Official Account articles found through Sogou's WeChat search |
| [NetEase Cloud Music Scraper](https://apify.com/parsebird/netease-cloud-music-scraper) | NetEase Cloud Music toplists and playlists with tracks, artists and popularity |

# Changelog

This Actor's version history is a separate document: https://apify.com/parsebird/baidu-tieba-scraper/changelog.md

# Actor input Schema

## `searchTerms` (type: `array`):

Enter keywords to search Tieba posts. Each keyword runs as a separate search and gets up to <b>Max posts</b> results.

## `sortSearchBy` (type: `string`):

Choose the order of search results.

## `searchWithinForum` (type: `string`):

Enter a forum (吧) name, ID or URL to search inside that forum only, like <code>电影吧</code> or <code>https://tieba.baidu.com/f?kw=电影</code>. Leave empty to search all of Tieba.

## `forums` (type: `array`):

Add forums (吧) to scrape by tab. Each entry takes <code>forum</code> (name, ID or URL), <code>tabs</code> (any of <code>highlights</code>, <code>popular</code>, <code>latest</code>, <code>video</code>), optional <code>customTabs</code> (the forum's own tab names in Chinese, exactly as shown on Tieba, like <code>影视评论</code>) and optional <code>maxPostsPerTab</code>. Without tabs, the <code>latest</code> tab is scraped.

## `urls` (type: `array`):

Add Tieba links: post links (<code>https://tieba.baidu.com/p/10860925843</code>), user profile links (<code>https://tieba.baidu.com/home/main?id=tb.1.…</code> or <code>?un=name</code>), hot topic links (<code>https://tieba.baidu.com/hottopic/browse/hottopic?topic_id=…</code>) and forum links (<code>https://tieba.baidu.com/f?kw=…</code>, latest tab).

## `topics` (type: `array`):

Enter Tieba hot topic (话题) names, like <code>剧情</code> or <code>#剧情</code>. Topic links also work in <b>Direct URLs</b>.

## `sortTopicPostsBy` (type: `string`):

Choose the order for topics and hot topic links: <b>Hottest</b> (Tieba's 最热) or <b>Latest</b> (newest first, 最新).

## `maxCommentsPerPost` (type: `integer`):

Set how many top-level comments (楼层 floors) to save for each post. Use <b>0</b> to skip comments.

## `maxRepliesPerComment` (type: `integer`):

Set how many replies (楼中楼) to save under each comment. Use <b>0</b> to skip replies.

## `sortCommentsBy` (type: `string`):

Choose the comment order: <b>Popular</b> (Tieba's hot floors first, then thread order), <b>Latest</b> (newest first) or <b>Oldest</b> (thread order).

## `maxPosts` (type: `integer`):

Set how many posts to save for each search term, topic, hot topic, user profile or forum link. Forum tabs use <code>maxPostsPerTab</code> when set. Use <b>0</b> for no limit.

## `proxyConfiguration` (type: `object`):

Not needed: Tieba's public data works without a proxy. Set one only if Tieba starts refusing requests.

## Actor input object example

```json
{
  "searchTerms": [
    "AI"
  ],
  "sortSearchBy": "most_relevant",
  "forums": [
    {
      "forum": "科技吧",
      "tabs": [
        "latest"
      ],
      "maxPostsPerTab": 5
    }
  ],
  "urls": [
    {
      "url": "https://tieba.baidu.com/p/10860925843"
    }
  ],
  "sortTopicPostsBy": "hottest",
  "maxCommentsPerPost": 5,
  "maxRepliesPerComment": 0,
  "sortCommentsBy": "latest",
  "maxPosts": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchTerms": [
        "AI"
    ],
    "forums": [
        {
            "forum": "科技吧",
            "tabs": [
                "latest"
            ],
            "maxPostsPerTab": 5
        }
    ],
    "urls": [
        {
            "url": "https://tieba.baidu.com/p/10860925843"
        }
    ],
    "maxCommentsPerPost": 5,
    "maxPosts": 10,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("parsebird/baidu-tieba-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchTerms": ["AI"],
    "forums": [{
            "forum": "科技吧",
            "tabs": ["latest"],
            "maxPostsPerTab": 5,
        }],
    "urls": [{ "url": "https://tieba.baidu.com/p/10860925843" }],
    "maxCommentsPerPost": 5,
    "maxPosts": 10,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("parsebird/baidu-tieba-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchTerms": [
    "AI"
  ],
  "forums": [
    {
      "forum": "科技吧",
      "tabs": [
        "latest"
      ],
      "maxPostsPerTab": 5
    }
  ],
  "urls": [
    {
      "url": "https://tieba.baidu.com/p/10860925843"
    }
  ],
  "maxCommentsPerPost": 5,
  "maxPosts": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call parsebird/baidu-tieba-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,parsebird/baidu-tieba-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/2lZJPkFjHaCZ8p895/builds/jKGa1pRridfWgiwbK/openapi.json
