【转】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 748 Shortest Completing Word 解题报告
题目要求 Find the minimum length word from a given dictionary words, which has all the letters from the ...
- Vue子组件调用父组件的方法
Vue子组件调用父组件的方法 Vue中子组件调用父组件的方法,这里有三种方法提供参考 第一种方法是直接在子组件中通过this.$parent.event来调用父组件的方法 父组件 <temp ...
- 怎么使用JavaScript进行进制转换
JS 是一个很神奇的语言,内制的的很多函数可以帮我们进行数(进)制转换: JS中可以直接使用16进制: var a = 0xff; //255 将任意进制字符串转换为十进制,如二进制,八进制,十六进制 ...
- 运维自动化工具ansible
企业级自动化运维工具应用实战ansible 公司计划在年底做一次大型市场促销活动,全面冲刺下交易额,为明年的上市做准备.公司要求各业务组对年底大促做准备,运维部要求所有业务容量进行三倍的扩容,并搭建出 ...
- ORACLE安装入门篇OEL5.4安装ORACLE11g
一.安装ORACLE11g软件(11.2.0.0) (一)安装前的包支持 1.检测yum仓库是否已经配置好 yum list all 2.搭建yum仓库 1).挂载所需要的安装光盘 虚拟机挂载光盘: ...
- python 字符串、列表和元祖之间的切换
>>> s=['http','://','www','baidu','.com'] >>> url=''.join(s) >>> url 'htt ...
- vue 动态绑定背景图片
html <div class="racetm" :style="{backgroundImage: 'url(' + (coverImgUrl ? coverIm ...
- mysql 分组 列转行
SELECT aa.type,CONCAT('(',GROUP_CONCAT('\'',aa.user_id separator '\'\,'),'\')') FROM (select aa.typ ...
- GOROOT、GOPATH、GOBIN
GOROOT golang安装路径. GOPATH GOPATH可以设置多个工程目录,linux下用冒号分隔(必须用冒号,fish shell的空格分割会出错),windows下用分号分隔,但是go ...
- Scala集合(一)
Scala集合的主要特质 Iterator,用来访问集合中所有元素 val coll = ... // 某种Iterable val iter = col.iterator while(iter.ha ...