For AI

Answers

How do I export Weibo search results to Excel?

Short answer

Page through Weibo post search for your keyword and write each post as a row with openpyxl, keeping post and user IDs as text and times in Beijing time. Each page holds about 10 posts for $0.002, so 30 pages (around 300 posts) cost $0.06; adding profiles for 120 unique authors with Weibo account profile brings it to $0.30.

The request is always the same: "send me what people are saying on Weibo about 露营 装备, in Excel". The search part is easy. The spreadsheet part is where exports go wrong: post IDs lose their last digit, Chinese turns into garbage, and every time is eight hours off. This page does the search with one endpoint and writes an .xlsx that opens cleanly.

The columns you get

From Weibo post search with view=full:

Column Field
Post ID (mid) id
Link url, in the form weibo.com/uid/bid
Author UID, name, followers author.id, author.name, author.followers
Published published_at (UTC; convert to Beijing)
Text text
Reposts, comments, likes metrics.reposts, metrics.comments, metrics.likes
Video plays metrics.views, for video posts only
IP region shown on the post ext.region
Text cut short in search ext.is_long_text

Shares and favorites are not public on Weibo; they come back null with platform in meta.unavailable. For more on each author, such as verification text and post count, look up the unique author.id values with Weibo account profile.

Three Excel traps

  1. Long IDs. A Weibo post ID has 16 digits, and Excel keeps only 15 significant digits of a number, so 5249013377610245 becomes 5249013377610240, displayed as 5.24901E+15. Users of open-source Weibo scrapers report exactly this. Write IDs as text, which openpyxl does when you pass a string.
  2. Encoding. A CSV opened by double-click can show garbled Chinese, another regular complaint in scraper issue trackers. Writing .xlsx avoids the question entirely.
  3. Time zone. published_at is UTC. Convert to Beijing time (UTC+8) before writing, and say so in the header.

Cost

Export Calls Cost
One page, about 10 posts 1 $0.002
30 pages, about 300 posts 30 $0.06
The same plus 120 author profiles 150 $0.30

Example

Install requests and openpyxl, set your key, then:

import os, requests
from datetime import datetime, timezone, timedelta
from openpyxl import Workbook

API = "https://api.okdata.online"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}
BJ = timezone(timedelta(hours=8))
QUERY, MAX_PAGES = "露营 装备", 30

def call(path, **params):
    body = requests.get(API + path, headers=H, params=params, timeout=60).json()
    if body["code"] != "ok":
        raise RuntimeError(f'{body["code"]}: {body["message"]}')
    return body

wb = Workbook()
ws = wb.active
ws.title = "posts"
ws.append(["mid", "link", "uid", "author", "followers", "published (Beijing)", "text",
           "reposts", "comments", "likes", "plays", "IP region", "text cut"])
seen, cursor = set(), None
for _ in range(MAX_PAGES):
    params = {"query": QUERY, "sort": "latest", "view": "full"}
    if cursor:
        params["cursor"] = cursor
    body = call("/v1/weibo/posts/search", **params)
    for p in body["data"]["items"]:
        if p["id"] in seen:
            continue
        seen.add(p["id"])
        when = datetime.fromisoformat(p["published_at"].replace("Z", "+00:00")).astimezone(BJ)
        m, a = p["metrics"], p["author"]
        ws.append([p["id"], p["url"], a["id"], a["name"], a["followers"], when.replace(tzinfo=None),
                   p["text"], m["reposts"], m["comments"], m["likes"], m["views"],
                   p["ext"].get("region"), p["ext"].get("is_long_text")])
    if not body["page"]["has_more"]:
        break
    cursor = body["page"]["next_cursor"]

wb.save("weibo-camping.xlsx")  # IDs were written as strings, so all 16 digits survive

To add an "authors" sheet, call /v1/weibo/users/get with id=<uid> and view=full once per unique author.id and write name, followers, posts, verified, ext.verified_reason and ext.ip_location.

Limits

  • Weibo search returns what Weibo ranks for the keyword, not every post ever made. For wider coverage, run sort=hot and sort=latest and merge by id, as in collecting Weibo posts for public-opinion analysis.
  • Posts marked ext.is_long_text arrive with the shortened text Weibo shows in search. The catalog has no Weibo post detail endpoint to fetch the full text.
  • No Weibo login or cookie is involved; see searching Weibo without a cookie. Only public posts are returned.

Sources

  1. Microsoft Support: Keeping leading zeros and large numbers in Excelsupport.microsoft.com · read
  2. openpyxl documentationopenpyxl.readthedocs.io · read
  3. dataabc/weibo-search issue 208: post ids shown as 4.75E+15 in Excelgithub.com · read
  4. dataabc/weiboSpider issue 565: garbled text when writing CSVgithub.com · read

Where people asked this (read 2026-11-12)

Updated

Connect once, then just ask.

Every new key comes with $0.10 to try it. One sentence connects your agent.

Start free
Connect your AI

Paste this into your agent

Read https://okdata.online/agents.md and set up okdata for me; my key is in the OKDATA_API_KEY environment variable.

Claude Code, Cursor, Codex and other agents that can open a link set themselves up from it.

MCP serverhttps://api.okdata.online/mcp