Hello

I made a program that submits a paragraph to a webpage, using mechanize.

Its all working great, except when I view the paragraph, all the newlines have disappeared and it makes all the paragraphs all block up together into one long sentence.

But when I open up the page on the website to edit the paragraph I just submitted with my program, all the newlines are there and its NOT blocked up into one long sentence. If I save my edit via the webpage, it then displays normally when viewing it on the webpage I submitted it to originally.

I then added a script using python and mechanize to edit it through the website In the hope it would then display normally and NOT in one long sentence with no newlines. This did not solve it though.


So in summary, there must be some kind of difference between the mechanize settings and the settings of firefox, such that mechanize does not submit the correct info to get it displaying correctly.


Here is an example of what the paragraph that is submitted by my program using mechanise to the webform looks like:

This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence. And so forth.

Here is what it looks like if you go an edit it (without making changes) via the website with an ordinary browser:

This is a sentence.
This is a sentence.
This is a sentence.

This is a sentence.
This is a sentence.
This is a sentence.

This is a sentence.
This is a sentence.
This is a sentence.


I am thinking its something to do with maybe the headers that mechanize sends? ie, the accept-language or accept-encoding or accept-charset ? or lack of

Has anyone came across this before?

I think I found the problem
-> Somewhere in the code its stripping the carriage returns \r away and leaving only the \n. So it starts off being \r\n, and comes out \n for some reason.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.