# How do I get IP location (IP属地) data from Weibo posts and Bilibili comments?

> Get the IP location (IP属地) that Weibo and Bilibili display: per Weibo post, per Weibo profile and per Bilibili comment. Which endpoint has it, cost, code, caveats.

Canonical page: https://okdata.online/answers/weibo-bilibili-ip-location-data/

**Short answer: **On Bilibili, every comment from Bilibili video comments carries ip_location, at $0.002 per page of about 20. On Weibo, ask for view=full: post search then puts each post's location in ext.region ($0.002 a page), and account profile puts the account's location in ext.ip_location ($0.002 each).

A hotpot chain from Chengdu opens its first stores in Shanghai and posts a launch video on Bilibili. Marketing wants to know whether the excitement in the comments comes from Shanghai or from homesick Sichuan viewers elsewhere. Both platforms print an IP location on public content, and you can count it at scale.

## Where the field lives

| Platform | Endpoint | Field | Level |
|---|---|---|---|
| Bilibili | [Bilibili video comments](/apis/bilibili/videos/comments/list/) | `ip_location` on each comment | Per comment |
| Weibo | [Weibo post search](/apis/weibo/posts/search/) with `view=full` | `ext.region` on each post | Per post |
| Weibo | [Weibo account profile](/apis/weibo/users/get/) with `view=full` | `ext.ip_location` | Per account |

The values are the place names the platforms show, usually a province such as 上海 or 四川, or a country for overseas users. The "IP属地" and "发布于" prefixes are already stripped.

## Cost

| Job | Calls | Cost |
|---|---|---|
| 1,000 Bilibili comments | 50 | $0.10 |
| 1,000 Weibo posts | 100 | $0.20 |
| 200 Weibo account profiles | 200 | $0.40 |

## Counting provinces

```python
import os, requests
from collections import Counter

API = "https://api.okdata.online"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}

def pages(path, n, **p):
    cursor = None
    for _ in range(n):
        r = requests.get(API + path, headers=H, timeout=30,
                         params={**p, **({"cursor": cursor} if cursor else {})}).json()
        if r["code"] != "ok":
            print(path, r["code"]); return
        yield from r["data"]["items"]
        if not r["page"]["has_more"]:
            return
        cursor = r["page"]["next_cursor"]

bili = Counter(c["ip_location"] for c in pages("/v1/bilibili/videos/comments/list", 25,
               id="BV1xx411c7mD", sort="latest", fields="ip_location"))
weibo = Counter(p["ext"].get("region") for p in pages("/v1/weibo/posts/search", 50,
                query="成都火锅 上海", view="full", fields="ext.region"))
print("Bilibili", bili.most_common(10))
print("Weibo", weibo.most_common(10))
```

## Read it carefully

- It is where the IP address was, not where the person lives. Travel, VPNs and mobile roaming all move it.
- Old posts and comments from before the platforms began showing locations have none. Missing values come back null and the field is listed in `meta.unavailable`.
- Use it in aggregate. A province count across 1,000 comments is market research; tracking one person's location is not something to build.
- Weibo comments are not in the catalog, so on Weibo you get the location of posts and accounts, not of replies.

## Other ways

For your own videos, Bilibili's creator centre shows audience regions, and Weibo's account analytics do the same for your followers. Those numbers cover viewers who never comment, so they are the better source for your own channel. For competitors' content, the public field above is what you can see. More ways to read public reaction are on [word of mouth](/solutions/word-of-mouth/).

## Endpoints used

- [Bilibili video comments](https://okdata.online/apis/bilibili/videos/comments/list/) `bilibili.videos.comments.list`: $0.002 per call · about 20 comments per page
- [Weibo post search](https://okdata.online/apis/weibo/posts/search/) `weibo.posts.search`: $0.002 per call · about 10 posts per page
- [Weibo account profile](https://okdata.online/apis/weibo/users/get/) `weibo.users.get`: $0.002 per call

Updated 2026-11-12
