save gb-2312 web page in a .html file

2007-12-26 Thread Peter Pei
I am trying to read a web page and save it in a .html file. The problem is that the web page is GB-2312 encoded, and I want to save it to the file with the same encoding or unicode. I have some code like this: url = 'http://blah/' headers = { 'User-Agent' : 'Mozilla/4.0 (compatible; MSIE

Re: save gb-2312 web page in a .html file

2007-12-26 Thread Peter Pei
You must be right, since I tried one page and it worked. But there is something wrong with this particular page: http://overseas.btchina.net/?categoryid=-1. When I open the saved file (with IE7), it is all messed up. url = 'http://overseas.btchina.net/?categoryid=-1' headers = { 'User-A

Re: save gb-2312 web page in a .html file

2007-12-26 Thread Peter Pei
I "view sourced" the original web page in IE7, and it does specify: So sounds like the encoding is gb2312... -- http://mail.python.org/mailman/listinfo/python-list

ElementTree should parse string and file in teh same way

2007-12-30 Thread Peter Pei
One bad design about elementtree is that it has different ways parsing a string and a file, even worse they return different objects: 1) When you parse a file, you can simply call parse, which returns a elementtree, on which you can then apply xpath; 2) To parse a string (xml section), you can ca

Re: ElementTree should parse string and file in the same way

2007-12-31 Thread Peter Pei
. You didn't understand the issue I described? That's your issue. You are not at the same level to talk to me, so chill. === "Stefan Behnel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >

Re: ElementTree should parse string and file in the same way

2007-12-31 Thread Peter Pei
To be preise, XPath is not fully supported. Don't be a smart asshole. = "Stefan Behnel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Peter Pei wrote: >> One bad design about elemen

Re: ElementTree should parse string and file in the same way

2008-01-01 Thread Peter Pei
To answer something posted deep down... It is fine with me if there are two functions - one to parse a file or file handler and one to parse a string, yet the returned objects should be consistent. -- http://mail.python.org/mailman/listinfo/python-list

how to make format operator % work with unicode as expected

2008-01-26 Thread Peter Pei
I am using things like "%-20s%-60s%-10s" in tkinter listbox to make it look like a table, with mono sized font like lucie system. But this does not work with data contains "Les misérables", because it is unicode, and one byte is not neccessary one character. Now how can I resolve this issue? My

Re: how to make format operator % work with unicode as expected

2008-01-26 Thread Peter Pei
I probably should mention that what I want is to make all parts of the string aligned, and look like table. I am not looking for other ways to make it table-alike, but only interested in making % work with unicode -counting characters not bytes... -- http://mail.python.org/mailman/listinfo/pytho

Re: how to make format operator % work with unicode as expected

2008-01-26 Thread Peter Pei
on't argue back and I am only interested in answers from those who are qualified. == "Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 27 Jan 2008 04:06:45 +,

Re: how to make format operator % work with unicode as expected

2008-01-26 Thread Peter Pei
I just sorted posts by from, and figured out that you are kind of PSF guy... However that does not make you qualified, I care whether you are capable not whether you have the time to spend for PSF. Adios! == "Peter Pei" <[EMAIL PROTECT

Re: how to make format operator % work with unicode as expected

2008-01-26 Thread Peter Pei
For sure I can calculate the number of characters and do the padding myself, but what's the point, and i surely hope that python does it for me. ==== "Peter Pei" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I am using things like "%-20s%-60

Re: how to make format operator % work with unicode as expected

2008-01-27 Thread Peter Pei
"I V" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 27 Jan 2008 05:32:40 +, Peter Pei wrote: >> Yes, it is true that %s already support unicode, and I did not >> contradict that. But it counts the number of bytes instead of >> ch

Re: how to make format operator % work with unicode as expected

2008-01-27 Thread Peter Pei
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 27 Jan 2008 05:32:40 +, Peter Pei wrote: > >> You didn't understand my question, but thanks any way. >> >> Yes, it is true that %s already support unicod

Re: how to make format operator % work with unicode as expected

2008-01-27 Thread Peter Pei
"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sun, 27 Jan 2008 05:32:40 +, Peter Pei wrote: > >> You didn't understand my question, but thanks any way. >> >> Yes, it is true that %s already

sortable table in python 3.0

2009-02-07 Thread Peter Pei
In one of my program, I used something called MultiColumnList, which is one of the sortable table widgets done in python. However 3.0 sort is different. I googled and found couple of other implementations, but all in python 3.0 -. Does anyone know any solution in 3.0? or anything that has alre