Skip to main content

BaiduTongjiAPI

百度统计 API 的 Python 封装

支持范围

账号类型 支持情况
百度商业账号 ❌
百度账号 ✅
API 支持情况
Token 刷新 ✅
站点列表 ✅
网站概况(趋势数据) ✅
网站概况(地域分布) ✅
网站概况(来源网站、搜索词、入口页面、受访页面) ✅
趋势分析 ✅
实时访客 ✅
推广方式 ❌
百度推广趋势 ❌
全部来源 ✅
搜索引擎 ✅
搜索词 ✅
外部链接 ✅
指定广告跟踪 ❌
受访页面 ✅
入口页面 ✅
受访域名 ✅
地域分布 ✅
地域分布(按国家) ✅

Doc

百度统计官方文档:

具体使用详见源代码,下面是对项目结构:

baidutongji
├── __init__.py
├── api.py          # API 定义
├── data.py         # 可选参数数据结构
└── metrics.py      # 各 API 筛选指标数据结构

使用样例:

  • 查询站点今天的网站概况(趋势数据)报表:
    import baidutongji
    
    baidutongji.getTimeTrendRpt('{ACCESS_TOKEN}', '{SITE_ID}', datetime.date.today(), datetime.date.today(), TimeTrendRptMetrics(pv_count=True, visitor_count=True, ip_count=True, bounce_ratio=True, avg_visit_time=True))
    
    或者可以简化:
    import baidutongji
    
    baidutongji.getTimeTrendRpt('{ACCESS_TOKEN}', '{SITE_ID}', datetime.date.today(), datetime.date.today(), TimeTrendRptMetrics().setAllTrue())
    
  • 查询 2022/01/01 ~ 2022/01/10 与 2022/04/01 ~ 2022/04/10 趋势分析对比报表,指定时间粒度以天为单位,筛选用户为老用户,访问设备为 PC,地区为上海市:
    import baidutongji
    
    baidutongji.getTrendTime('{ACCESS_TOKEN}', '{SITE_ID}', datetime.date(2022, 1, 1), datetime.date(2022, 1, 10), TrendTimeMetrics().setAllTrue(), datetime.date(2022, 4, 1), datetime.date(2022, 4, 10), Source.ALL, ClientDevice.PC, VisitorType.RETURN, TimeGran.DAY, Region(RegionType.PROVINCE, '上海'))
    

Metadata

Release files for baidutongji 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for baidutongji 0.1.6
File Size Uploaded Provenance
baidutongji-0.1.6.tar.gz 7.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for baidutongji 0.1.6
File Interpreter ABI Platform
baidutongji-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / baidutongji-0.1.6.tar.gz

Download URL baidutongji-0.1.6.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6f1fb2c48432e7bc938ae849ea5f222c73e2a173710913a1569545ac378f493b
BLAKE2b-256 checksum
How to use checksums
b84bbc4cc4e1ce3c463e84cc152377f0d8455255b48069a11836fd7f0ed5e83d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / baidutongji-0.1.6-py3-none-any.whl

Download URL baidutongji-0.1.6-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
468b6cc758d18c88c0cb540b312941200395c3c7a182b639f462be9f8099622a
BLAKE2b-256 checksum
How to use checksums
52c0f8c2bd93e2ba62b3d20d1bd42f89161c06c6dd85afa31e9d68653eba7fc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for baidutongji 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page