Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > urllib2.Request:: http Request sending successfully, but Responsecontains in valid data.

Reply
Thread Tools

urllib2.Request:: http Request sending successfully, but Responsecontains in valid data.

 
 
nRk
Guest
Posts: n/a
 
      02-11-2009
Hi

I am trying to send Data to a website through "http" using
"urllib.request" library using the bellow code.
Response status code contains. 200 (OK) but Response contains
nothing...

With same data When I test using C# it working fine.. Response
having.. some data in xml format.
But I am using below python code i am getting response only "<HTML></
HTML>".

Is there any in my code..

req = urllib2.Request(url) // url is valid url
req.add_header('Authorization','AuthSub token="xxxxxxxxxxxxx"')
req.add_header('Content-Type','application/atom+xml')
req.data=data // data is having valid xml data
r = urllib2.urlopen(req)

print(r.code) // output 200
print(r.msg) // output OK
print(r.read()) //<HTML></HTML>
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      02-12-2009
On Wed, 11 Feb 2009 01:56:19 -0800, nRk wrote:

> Hi
>
> I am trying to send Data to a website through "http" using
> "urllib.request" library using the bellow code. Response status code
> contains. 200 (OK) but Response contains nothing...


No it doesn't, you say so later: it contains a set of bare <HTML></HTML>
tags. That's not the same as nothing.

>
> With same data When I test using C# it working fine.. Response having..
> some data in xml format.
> But I am using below python code i am getting response only "<HTML></
> HTML>".
>
> Is there any in my code..
>
> req = urllib2.Request(url) // url is valid url


This is not your real code.

>>> import urllib2
>>> req = urllib2.Request(url) // url is valid url

File "<stdin>", line 1
req = urllib2.Request(url) // url is valid url
^
SyntaxError: invalid syntax


How do you expect us to find bugs in your code when you don't show us
your real code? Are we supposed to be mind-readers?


Try using the same user-agent string as your C# code uses, and see if the
server changes what it sends.



--
Steven
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending XML files through HTTP Request/Response. EJONES Java 1 08-09-2006 09:32 PM
http request with cookie sending itay_k Python 2 04-20-2006 07:43 PM
Server side-error occurred on sending debug HTTP request. darrel ASP .Net 3 10-21-2005 02:29 PM
Server side-error occurred on sending debug HTTP request Lessandro Sant'Ana ASP .Net 1 06-09-2004 01:36 PM
Sending http-request with multipart/form-data Axel Heck C++ 1 10-20-2003 12:18 PM



Advertisments