Hi folks,

I tried to open some web pages with urllib2.Request(url, data, headers), but
it always give me a 404 error.
Eg.
url = 'http://www.whatever.com/somephp.php'
data = {}
data['id'] = account
for i in book2Open:
    data['book'] = i
    url_data = urllib.urlencode(data)
    request = urllib2.Request(url, url_data, headers)
    response = urllib2.urlopen(request)
    html = response.read()
==> HTTPError: HTTP Error 404: Not Found


However, the page is retrievable when I manually put url and data together.
Eg.
url = 'http://www.whatever.com/somephp.php'
data = {}
data['id'] = account
for i in book2Open:
    data['book'] = i
    url_data = urllib.urlencode(data)
    full_url = url + '?' + url_data
    request = urllib2.Request(full_url, "", headers)
    response = urllib2.urlopen(request)
    html = response.read()
==> works fine

Any idea ?


-- 
This is a UTF-8 formatted mail
-----------------------------------------------
James C.-C.Yu
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to