【转】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)将显 ...
随机推荐
- LeetCode 657 Robot Return to Origin 解题报告
题目要求 There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of it ...
- linux read()和write
参考http://www.cnblogs.com/xiehongfeng100/p/4619451.html 1. read总是在接收缓冲区有数据时立即返回,而不是等到给定的read buffer填满 ...
- min-max容斥笔记及例题
这个东西是一个非常好玩的数学工具. $$max(S)=\sum_{T\subset S}(-1)^{|T|-1}min(T)$$ $$max_k(S)=\sum_{T\subset S}(-1)^{| ...
- Innodb semi-consistent 简介
A type of read operation used for UPDATE statements, that is a combination of read committed and con ...
- .NET Core 使用 Kestrel
Kestrel介绍 Kestrel是一个基于libuv的跨平台web服务器 在.net core项目中就可以不一定要发布在iis下面了 Kestrel体验 可以使用useUrls来设置一个请求的地址 ...
- 显示隐藏火车头快捷键Ctrl+t
今天ytkah在使用火车头的时候也使用了Photoshop,用了组合键Ctrl+t来进行调整图层的大小,可能多按了几次的缘故吧,触发了火车头的隐藏老板键,找了半天也找到,因为当时编辑的任务还没保存,不 ...
- Python3学习之路~6.6 类的继承
Inheritance 继承 面向对象编程 (OOP) 语言的一个主要功能就是“继承”.继承是指这样一种能力:它可以使用现有类的所有功能,并在无需重新编写原来的类的情况下对这些功能进行扩展.通过继承创 ...
- os.path的使用
os.path 1.返回当前目录 举个例子: (1)给出一个目录名称,返回绝对路径 project_path = "Exercise" path = os.path.dirname ...
- centOS和windows7双系统下重装windows后恢复centOS引导
电脑原本是windows7和centOS双系统,后来重装windows系统后,发现没有centOS引导,于是重新恢复centOS引导. 1.官网下载centos系统镜像CentOS-7-x86_64- ...
- [django]django models最佳实战
models class People(models.Model): name = models.CharField(max_length=30) age = models.CharField(max ...