本技能通过国家统计局 RSS 抓取《70个大中城市商品住宅销售价格变动情况》,返回可直接供 agent 总结的结构化数据。
依赖:Python 3、requests、beautifulsoup4,以及在需要图表时可用的 matplotlib。运行时需要能访问 stats.gov.cn。
--latest--limit python3 scripts/fetch_data.py --city <城市> --metrics <指标> --latest
python3 scripts/fetch_data.py --city <城市> --metrics <指标> --limit 24
python3 scripts/fetch_data.py --city <城市> --chart --limit 24
--city:目标城市,支持常见输入变体,如 北京市--metrics:逗号分隔,支持 环比、同比、定基--latest:只返回最新一期--limit:返回最近 N 期历史数据--chart:生成图表--output:图表输出路径--no-cache:禁用缓存指标别名可直接输入:mom、yoy、环比指数、同比指数、fixed-base。
重点看这些字段:
requested_city:用户请求的城市输入matched_city:脚本最终匹配到的规范城市名latest_period:本次结果中的最新期次record_count:返回记录数records:核心数据records 中每条记录包含:
periodcityindicatormetricssource_url新建商品住宅销售价格指数 -> 新建商品住宅二手住宅销售价格指数 -> 二手住宅100 为基准:100 表示上涨100 表示下降python3 scripts/fetch_data.py --city 武汉 --metrics 环比,同比 --latest
python3 scripts/fetch_data.py --city 上海市 --metrics yoy --limit 12
python3 scripts/fetch_data.py --city 北京 --metrics 环比,同比 --chart --limit 24
references/REFERENCE.md--output 覆盖共 1 个版本