【转】HTTP429
转载:http://codewa.com/question/45600.html
Q:How to avoid HTTP error 429 (Too Many Requests) python |
Q:如何避免HTTP错误429(请求太多)Python |
|
I am trying to use Python to login to a website and gather information from several webpages and I get the following error:
I used time.sleep() and it works, but it seems unintelligent and unreliable, is there any other way to dodge this error? Here's my code:
|
我试图用Python来登录到一个网站,收集信息,从几个网页,我收到以下错误:
我用的时间。sleep()和它的作品,但它似乎愚蠢和不可靠的,有没有其他的方式来逃避这个错误? 这是我的密码:
|
| answer1: | 回答1: |
|
Receiving a status 429 is not an error, it is the other server "kindly" asking you to please stop spamming requests. Obviously, your rate of requests has been too high and the server is not willing to accept this. You should not seek to "dodge" this, or even try to circumvent server security settings by trying to spoof your IP, you should simply respect the server's answer by not sending too many requests. If everything is set up properly, you will also have received a "Retry-after" header along with the 429 response. This header specifies the number of seconds you should wait before making another call. The proper way to deal with this "problem" is to read this header and to sleep your process for that many seconds. You can find more information on status 429 here: http://tools.ietf.org/html/rfc6585#page-3 |
429接收的状态是不是一个错误,这是其他服务器的“好心”请你停止滥发请求。显然,您的请求率太高,服务器不愿意接受。 你不应该寻求“道奇”,甚至试图绕过服务器安全设置试图欺骗你的IP,你应该尊重服务器的回答不给太多的要求。 如果一切都设置妥当,您也将收到一个“重试”后的头随着429响应。此标头指定要在调用另一个调用前等待的秒数。处理这个“问题”的正确方法是读取这个头,然后在你的睡眠过程中持续几秒钟。 你可以在这里找到状态429更多信息:HTTP:/ /工具。IETF。org / HTML / rfc6585 # page-3 |
| answer2: | 回答2: |
|
Another workaround would be to spoof your IP using some sort of Public VPN or Tor network. This would be assuming the rate-limiting on the server at IP level. There is a brief blog post demonstrating a way to use tor along with urllib2: http://blog.flip-edesign.com/?p=119 |
另一个解决方法是哄骗你的IP使用某种公共VPN或Tor网络。这将假设在IP级别的服务器上的速率限制。 有一个简短的博客文章来演示使用Tor和urllib2一起: http://blog.flip-edesign.com/?P = 119 |
| answer3: | 回答3: |
|
Writing this piece of code fixed my problem: requests.get(link, headers = {'User-agent': 'your bot 0.1'}) |
写这段代码修正了我的问题: 要求得到(链接、标题= { 'user-agent ':'你的BOT 0.1 }) |
【转】HTTP429的更多相关文章
- F12 开发人员工具中的控制台错误消息
使用此参考解释显示在 Internet Explorer 11 的控制台 和调试程序中的错误消息. 简介 使用 F12 开发人员工具进行调试时,错误消息(例如 EC7111 或 HTML1114)将显 ...
随机推荐
- 【PyQt5-Qt Designer】界面布局
PyQt5 界面布局详谈 箱式布局 QHBoxLayout和QVBoxLayout是基本的布局类,它们在水平和垂直方向上排列小部件 效果图: from PyQt5.QtCore import Qt f ...
- Apache SSL 服务搭建
Web服务器在默认情况下使用HTTP,这是一个纯文本的协议.正如其名称所暗示的,纯文本协议不会对传输中的数据进行任何形式的加密.而基于HTTP的Web服务器是非常容易配置,它在安全方面有重大缺陷.任何 ...
- winform嵌入word解决方案一
最近一直想用VC#2005做个内嵌WORD/OFFICE的WINFORM程序,目前主要有以下解决途径: 1.直接通过API把WORD/OFFICE的窗口句柄给放到WINFORM中(感觉较为复杂): 2 ...
- MyBatis学习(01)之解决mapper绑定异常
解决mapper绑定异常 HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.bind ...
- Python3学习之路~3.3 内置函数
Python内置函数表: 内置参数详解:https://docs.python.org/3/library/functions.html?highlight=built#ascii 用法: #Auth ...
- open '/dev/hwlog_switch' fail -1, 13. Permission denied
https://blog.csdn.net/qq_36317441/article/details/79376522 将HBuilder开发的APP运行在华为手机上时,控制台显示 open '/dev ...
- 修改vs2010中html的默认模板
用vs2010开发,新建html时,html页面会生成HTML 4 XHTML的header,如何把它改成干净的html5风格? 步骤: 修改 你的安装目录\Microsoft Visual Stud ...
- jenkins借助winscp传本地文件到远程服务器上
有这样的场景,我们的ftp上都是些重要的资料,所以大家基本只有可看的权限,只有部分管理人员有可读可写的权限,但是jenkins上基本使用的都是ftp的路径,这个时候就存在一些问题,某些开发需要将自己构 ...
- 备份软件 FreeFileSync 怎么用
现在,学会使用备份软件对电脑中的重要资料定期进行备份,已经成为许多办公一族的“必修课”.其中,FreeFileSync 作为一款由国外开源社区开发的免费备份软件,由于其支持跨平台(Windows.Li ...
- cocos2d-x C++ (利用定时器自定义屏幕双击事件函数)
//GameScene.h #include "cocos2d.h" USING_NS_CC; class GameScene : public cocos2d::Layer { ...