Z
Z
zholdas2012-03-31 15:20:54
Python
zholdas, 2012-03-31 15:20:54

Error when requesting via urllib2.Request

I execute the code: Exception crashes: urllib2.HTTPError: HTTP Error 507: Insufficient Storage What could be the problem?
req = urllib2.Request("http://tutu.ru/poezda/station_d.php?nnst=2600186")
response = urllib2.urlopen(req)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
Elkaz, 2012-03-31
@Elkaz

507 Insufficient Storage - There is not enough space to complete the current request. The problem may be temporary. Introduced in WebDAV.

D
dimitrimus, 2012-03-31
@dimitrimus

funny, but I have the same problem with your code. I tried to use the urllib module - it works. I can't understand why this is so :) maybe urllib capabilities will be enough for the task?

K
krom9ra, 2012-03-31
@krom9ra

Server error - most likely, by default, urllib2 sends some “wrong” headers, or something like that.
A simple recipe is to catch the request that urllib2 sends with a sniffer and compare it with what is sent, for example, by browsers.
Maybe there is a problem with gzip or encoding - the same curl fulfills this request perfectly (checked with hundreds of requests)

S
sanzstez, 2012-03-31
@sanzstez

# -*- coding: utf-8 -*-

import urllib2

opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
data = opener.open('http://tutu.ru/poezda/station_d.php?nnst=2600186')
print data.read()

Try like this. My page loaded fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question