Re: Get document as normal text and not as binary data

2005-03-29 Thread Markus Franz
Kent Johnson wrote: My guess is the html is utf-8 encoded - your sample looks like utf-8-interpreted-as-latin-1. Try contents = f.read().decode('utf-8') YES! That helped! I used the following: ... contents = f.read().decode('utf-8') contents = contents.encode('iso-8859-15') ... That was the perfec

Re: Get document as normal text and not as binary data

2005-03-29 Thread Markus Franz
Diez B. Roggisch wrote: Addendum: If you give us the url you're fetching data from, we might be able to look at the delivered data ourselves. To guess my problem please have a look at the document title of Markus -- http://mail.python.org/mailman/l

Re: Get document as normal text and not as binary data

2005-03-28 Thread Kent Johnson
Markus Franz wrote: Hi. I used urllib2 to load a html-document through http. But my problem is: The loaded contents are returned as binary data, that means that every character is displayed like lÀÃt, for example. How can I get the contents as normal text? My guess is the html is utf-8 encoded - y

Re: Get document as normal text and not as binary data

2005-03-28 Thread Diez B. Roggisch
Addendum: If you give us the url you're fetching data from, we might be able to look at the delivered data ourselves. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list

Re: Get document as normal text and not as binary data

2005-03-28 Thread Diez B. Roggisch
Markus Franz wrote: > Diez B. Roggisch wrote: > >> You get what the server sends. That is always binary - either it _is_ a >> binary file, or maybe in an unknown encoding. > > And how can I convert those binary data to a "normal" string with > "normal" characters? There is no "normal" - it's ju

Re: Get document as normal text and not as binary data

2005-03-28 Thread Markus Franz
Diez B. Roggisch wrote: You get what the server sends. That is always binary - either it _is_ a binary file, or maybe in an unknown encoding. And how can I convert those binary data to a "normal" string with "normal" characters? Best regards Markus -- http://mail.python.org/mailman/listinfo/pyth

Re: Get document as normal text and not as binary data

2005-03-27 Thread Fredrik Lundh
Markus Franz wrote: > I used urllib2 to load a html-document through http. But my problem > is: The loaded contents are returned as binary data, that means that every > character is displayed like lÃ?Ãt, for example. How can I get the > contents as normal text? > > My script was: > > import urllib

Re: Get document as normal text and not as binary data

2005-03-27 Thread Diez B. Roggisch
Markus Franz wrote: > Hi. > > I used urllib2 to load a html-document through http. But my problem > is: > The loaded contents are returned as binary data, that means that every > character is displayed like lÀÃt, for example. How can I get the > contents as normal text? You get what the server