Python requests 错误
429 Client Error: Too Many Requests for url
当网站返回 429 时,raise_for_status() 会报出此错误。后面的 url 是你请求的页面。
你向该网站发出的请求过于频繁。
它要求你放慢速度。
这是什么意思
429 表示客户端在给定时间内发送的请求过多。服务器可能会添加 Retry-After 标头,说明需要等待多久。
限制通常按 IP 地址计算;对于在登录状态下发出的请求,也会按用户或密钥计算。限制可以覆盖整个网站,也可以只针对一个路径。
修复
- 从响应中读取
Retry-After,等待相应时长后再发送下一个请求。 - 在请求之间加入延迟,每次重复出现 429 后等待更长时间。
- 复用已获取的内容:缓存页面,只请求有变化的部分。
- 如果反复触发限制,说明该网站希望你使用它的 API 或付费套餐。
使用 superbot
superbot 的读取工具会指明速率限制,而不是抛出异常。它会返回 page_rate_limited 和以下信息,并在网站发送 Retry-After 值时一并传回:
page returned 429: the site is rate limiting readers. Read the same facts from another source, or read this page again later.
真实浏览器解决不了普通的速率限制,因此 superbot 不会用浏览器重试。下一步是换个来源,或稍后再访问同一页面。
提问
读取 https://httpbin.org/status/429 并告诉我它为什么打不开。
回复
It opened fine; httpbin answered with HTTP 429, an empty body by design.
…
httpbin's /status/<code> endpoint exists to return exactly that status code and nothing else, so 429 here is not a rate limit you hit and not a failure of your connection.此功能需要账号。
没有账号的智能体会通过 /auth.md 帮你登录。
你把邮件中的一个验证码读给智能体听。
相关内容
来源:MDN:429 请求过多。查阅于 2026-10-18。