Dev.to WebDev 🛠 Dev 👁 0 📖 5 min read

Why Chinese Platform Scrapers Are Rare (And Why That Matters)

I keep a file with sixty-nine Chinese endpoints in it, and seventeen of them return JSON I can use. That is not a list of failures, it is a taxonomy. Thirty-five answered 200 with an HTML page — the data is in there, wr

I keep a file with sixty-nine Chinese endpoints in it, and seventeen of them return JSON I can use.

That is not a list of failures, it is a taxonomy. Thirty-five answered 200 with an HTML page — the data is in there, wrapped in a shell, and extracting it is a different job from parsing an API. Seventeen answered with a login wall, a slider captcha, or a WAF marker. The rest were edge cases I had to adjudicate by hand.

None of those numbers is the hard part. The hard part starts after you get JSON back and it parses cleanly and it is still wrong.

The six walls, measured

Columns that were never going to fill. Weibo category: 30 of 30 null, then 10 of 10 null after removing the pinned item, then I deleted the field. Amap rating and cost: 15 of 15 null in Shanghai, 5 of 5 null in Beijing. Two cities is enough to conclude it is not a city bug.

Undocumented numeric enums. Douyin label took five distinct values across 30 records — 0 seven times, 1 seven times, 3 twelve times, 9 three times, 16 once. I can confirm 1 = new and 3 = hot by reading the badge in the UI. 9 and 16 have no published meaning, so they map to null and the raw integer survives in label_raw.

# Only map values confirmed against the rendered UI.
# Everything else stays None — and label_raw keeps the evidence.
LABEL_MAP = {0: None, 1: "new", 3: "hot"}

def map_label(raw):
    try:
        code = int(raw)
    except (TypeError, ValueError):
        return None
    return LABEL_MAP.get(code)     # 9 -> None, 16 -> None

print(map_label(3), map_label(9), map_label(16))
# hot None None

Anyone who guesses here ships a fabricated label with no way for a buyer to detect it.

The same field, populated in one mode only. Bilibili cid was null on 18 of 18 search records. Call the detail endpoint for the same video and you get 137649199. Same field name, same schema, different availability depending on which endpoint produced the row.

Errors that are not errors. Amap answers HTTP 200 with {"data": "城市参数不合法"} when the adcode is wrong — data is a string, not a dict, so payload["data"]["poi_list"] raises TypeError mid-batch and you lose everything after it. Xueqiu answers 400 with an empty body until you visit the homepage once and pick up xq_a_token. Douyin returns an empty word_list with status_code: 0 if the parameter blob looks stale.

Ambiguous identifiers. Eastmoney's K-line endpoint wants secid. 1.000001 is the Shanghai Composite Index; 0.000001 is 平安银行 at 12.23. Same six digits, two instruments, no warning either way. Xueqiu rejects HK00700 and silently accepts 00700.

Units and sentinels. Eastmoney writes - for missing values instead of null, and my 800-row pull had 239 negative dynamic PEs — those are loss-making companies, not corrupt rows. Turnover is CNY, volume is 手, which is 100 shares, and nothing in the payload says so.

Individually, each is a ten-minute fix. Together they are why a scraper for this market takes a week longer than the equivalent for a US site.

The script that finds these walls

I run this on every new source before writing a normalizer. It has caught every problem above at least once.

def profile(rows, fields=None, unique_key=None):
    if not rows:
        return {"error": "no rows"}
    fields = fields or list(rows[0].keys())
    n = len(rows)

    null_rate = {}
    for f in fields:
        nulls = sum(1 for r in rows if r.get(f) in (None, "", []))
        null_rate[f] = f"{nulls}/{n}"

    report = {"rows": n, "null_rate": null_rate}

    if unique_key:
        keys = [r.get(unique_key) for r in rows]
        report["unique"] = f"{len(set(keys))}/{n}"

    # constant columns are dead weight, not data
    report["constant"] = [f for f in fields if len({str(r.get(f)) for r in rows}) == 1]

    return report

print(profile(weibo_rows, ["word", "hot_value", "label", "category"], "word"))
# {'rows': 30,
#  'null_rate': {'word': '0/30', 'hot_value': '1/30', 'label': '8/30', 'category': '30/30'},
#  'unique': '30/30',
#  'constant': []}

The category: 30/30 line is the entire argument for deleting the column. A field that is null on every row costs schema width, documentation and buyer trust, and returns nothing.

The constant check is the same idea from a different angle: Douyin's discuss_video_count was 1 on all 30 records. Not a metric — a placeholder that made it into the payload.

What the probe file actually taught me

Sixty-nine endpoints, seventeen usable. Of the twenty-nine actor directories in this project, eleven went through one batch where build, run, real rows and pricing were all verified together. The gap between eleven and twenty-nine is not laziness, it is this: every source needs its own semantics documented before it counts as done.

The three buckets matter differently. A blocked endpoint is honest — you know where you stand. An HTML shell is a research project. A JSON endpoint that returns a field that is always null is the dangerous one, because it looks like success.

Build or buy

If your requirement is one platform and one field — "the current A-share price for 30 tickers, daily" — build it. Twenty lines, an afternoon, done.

If your requirement is a table that survives contact with a client, you are buying four things the endpoint will not give you:

  • Field semantics. Which nulls are normal, which mean broken.
  • Mode awareness. That cid lives in detail mode, that tel lives on the rendered page.
  • Enum mapping with restraint. 1 = new, 3 = hot, 9 = unknown-and-stays-unknown.
  • Someone watching for drift. These payloads change without notice. Amap's /service/poiInfo used to return JSON and now returns an HTML shell; that change arrived with no announcement and no version bump.

The counter-argument is fair: you can learn all of it yourself in a week of pulling data and staring at it. That week is the product.

And no, a proxy does not help with any of it. Rotating IPs solves the throttling wall, which is the cheapest of the six. It does nothing about category being 30/30 null, about secid meaning two different things, or about an endpoint answering 200 with a string where you expected a dict. My honest split of where the work goes: 10% HTTP, 30% normalizing field shapes, 60% discovering and documenting semantics. Proxies live entirely inside the first 10%.

I have these packaged with the semantics already encoded — null expectations, mode notes, enum mappings, and raw values kept beside the mapped ones: Eastmoney, Xueqiu, Bilibili, Weibo, Douyin, Amap.

Next step: run profile() against whatever JSON you already have lying around. If a column is 100% null, delete it today — and if a column is constant, ask yourself what you were planning to do with it.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.