错误200 python

时间:2017-04-26 23:12:55

标签: python proxy http-error

我尝试使用代理获取html,但服务器返回200

编辑: 更改用户代理请求

def proxi(self):
    print "proxy"
    n = random.randrange(0,1,1)
    if n == 0:
        print "es 0 "#52.183.30.241 8888
        link = 'http://162.243.77.188:3128'
    else:
        if n == 1:
            print "es 1" #54.183.3.46   80
            link = 'http://47.88.85.75:80'
    pro_s = urllib2.ProxyHandler({'http' : link })
    return pro_s

代理是:

send: u'GET http://mangadoor.com/manga/fairy-tail/521/1 HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: mangadoor.com\r\nConnection: close\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: openresty/1.11.2.2
header: Date: Thu, 27 Apr 2017 03:46:00 GMT
header: Content-Type: text/html; charset=UTF-8
header: Transfer-Encoding: chunked
header: Connection: close
header: Set-Cookie: __cfduid=d4b16b5d5caac66c54bd9a278abd397771493264759; expires=Fri, 27-Apr-18 03:45:59 GMT; path=/; domain=.mangadoor.com; HttpOnly
header: X-Powered-By: PHP/5.6.30
header: Cache-Control: no-cache
header: Set-Cookie: laravel_session=eyJpdiI6IndYOVlINnZsNG9yaENrM21MODNmd0E9PSIsInZhbHVlIjoiYXVWRHRmQThwbTQ1UDJxM1o0cEdmbnVxVkxOYzdxRm9sTk1jZmRpVndRM1l3SVwveWRWWGMxSm5VNGpwbm8zWEV5TEFtRFdzNmJzSEF3R3Axd0ZCK0R3PT0iLCJtYWMiOiI1YmE0NDUwN2YxMzYwY2RlMzA1ZjYwMDg2MTQ1ZjczZTM0NTczOWY0NWNjYzU2NGExMjAxYWFmOTE1NGE4OGExIn0%3D; expires=Thu, 27-Apr-2017 05:45:59 GMT; Max-Age=7200; path=/; httponly
header: Vary: Accept-Encoding
header: CF-RAY: 355ecacc3584186a-EWR

回应:

StrictHostKeyChecking

我的代码中存在什么问题?

1 个答案:

答案 0 :(得分:0)

看起来像服务器只允许GET / HEAD方法。

当您使用“”作为数据时,它会使用POST方法启动。这就是为什么你可能会收到一个不允许的方法。

如下所示更改请求行并查看结果: -

req = urllib2.Request(site,None,headers)