473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

httplib module

Why do I get double new lines when geting data from server? Example:

I have a following file:
------start-------------
<html>
<body>
Ovo je testni primjerak
</body>
</html>
------end---------------

And the code is:
conn = httplib.HTTPConnection("localhost:8000")
conn.request("GET", "/folder/index.html")
response = conn.getresponse()
reply = response.read()

print reply
<html>\n\n<body>\n\nOvo je testni primjerak\n\n</body>\n\n</html>\n\n

--
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
Jul 7 '07 #1
4 1414
Boris Ozegovic wrote:
Why do I get double new lines when geting data from server? Example:
Fixed.

--
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
Jul 7 '07 #2
Boris Ozegovic wrote:
Boris Ozegovic wrote:
>Why do I get double new lines when geting data from server? Example:

Fixed.
How? It's customary to include details when you've solved your own
problem in case someone else gets the same issue.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Jul 7 '07 #3
Steve Holden wrote:
>>Why do I get double new lines when geting data from server? Example:
How? It's customary to include details when you've solved your own
problem in case someone else gets the same issue.
Ok. In do_GET I had this two lines:

for line in file:
print line

As you can see, print inserted another \n. :-)

Correct code is:

for line in file:
print line,

--
Ne dajte da nas lažljivac Bandić truje:
http://cnn.blog.hr/arhiva-2007-06.html#1622776372
Jul 8 '07 #4
Boris Ozegovic wrote:
Steve Holden wrote:
>>>Why do I get double new lines when geting data from server? Example:
How? It's customary to include details when you've solved your own
problem in case someone else gets the same issue.

Ok. In do_GET I had this two lines:

for line in file:
print line

As you can see, print inserted another \n. :-)

Correct code is:

for line in file:
print line,
Thanks. Glad you got it sorted out.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Jul 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: berklee just berklee | last post by:
I have an ASP page which is returning a chart image that's being dynamically generated (by writing to the response object). When I try and access that page with httplib (to download said image),...
2
by: scummer | last post by:
Hi, I am having a problem with the httplib HTTPConnection object. While I can easily send requests that don't have any payload (ie. "get"), I encounter issues if I want to post xml data. If you...
1
by: Brian Beck | last post by:
Hi. I'm having some problems with code based directly on the following httplib documentation code: http://www.zvon.org/other/python/doc21/lib/httplib-examples.html I've included the code and...
0
by: Leon | last post by:
I use sniffer look,it's status is 200,but run getresponse() can occur error ResponseNotReady I try wait it by 5 seconds,but still occur error ResponseNotReady source code.... import...
0
by: Robert | last post by:
did you solve this problem? It seems to be still present here with py2.3.5. Robert -- From: Manish Jethani <manish.j@gmx.net> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;...
2
by: James Stroud | last post by:
Hello All, I want to use python to download files from sites where authentication is required. The page appears to send a form with the login and pass by post. I would like to log in and keep...
5
by: scott | last post by:
Hello, From a shell script, I have used /usr/bin/curl to access a web site and pass a cookie (as required by the site). But, I can't seem to accomplish this task with Python. I would like to...
5
by: runningwild | last post by:
Helo, This is the first time I have cared about httplib's HTTPSConnection. In the docs I read "Note: HTTPS support is only available if the socket module was compiled with SSL support." ...
4
by: Patrick Altman | last post by:
I am attempting to use a HEAD request against Amazon S3 to check whether a file exists or not and if it does parse the md5 hash from the ETag in the response to verify the contents of the file so...
3
by: rhXX | last post by:
hi all, i'm using this tutorial example import httplib h = httplib.HTTP("www.python.org") h.putrequest('GET','/index.html') h.putheader('User-Agent','Lame Tutorial Code')...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.