έγραψε:>>> import chardet
>>> import urllib2
>>> page=urllib2.urlopen("http://vancouver-webpages.com/multilingual/greek.html")
>>> contents= page.read()
>>> contents #
αλαμπουρνέζικα ...
'<HEAD>\n\n<TITLE>Greek / \xc7\xeb\xeb\xdd\xed\xe9\xea\xe1 (ISO 8859-7)</TITLE>\n\n\n\n</HEAD>\n<BODY>\n<H1>Greek / \xc7\xeb\xeb\xdd\xed\xe9\xea\xe1 (ISO 8859-7)</H1>\n<DD> \xc3\xe5\xe9\xdc \xf3\xe1\xf2\n<p>\n<a href="http://www.diavlos.gr/agelioforos/k01.htm">\nhttp://www.diavlos.gr/agelioforos/k01.htm</a><p>\n\n<hr>\nCITROEN VISA \xe1\xed\xf4\xe1\xeb\xeb\xdc\xf3\xe5\xf4\xe1\xe9 \xec\xe5 \xe1\xe3\xf1\xef\xf4\xe9\xea\xfc NISSAN *0382/32273<P>\r\n\xc3\xca\xc1\xd1\xd3\xcf\xcd\xc9\xc5\xd1\xc1 40 \xf4\xec \xf3\xf4\xe7 \xcd\xe5\xdc\xf0\xef\xeb\xe7 \xe1\xed\xf4\xe1\xeb\xeb\xdc\xf3\xf3\xe5\xf4\xe1\xe9 \xec\xe5 \xe3\xf1\xe1\xf6\xe5\xdf\xef 30-40 \xf4\xec \xf3\xf4\xef \xea\xdd\xed\xf4\xf1\xef *869544 \xe1\xf0\xfc\xe3\xe5\xf5\xec\xe1 \xea\xe1\xe9 *287572 \xf0\xf1\xf9\xdf<P>\r\n\xc4\xc9\xc1\xcc. \xf3\xf4\xef \xea\xdd\xed\xf4\xf1\xef \xec\xe5 \xe1\xf3\xe1\xed\xf3\xdd\xf1 \xea\xe1\xe9 \xea\xe1\xeb\xef\xf1\xe9\xf6\xdd\xf1 \xe1\xee\xdf\xe1\xf2 27.000.000 \xe4\xf1\xf7 \xe1\xed\xf4\xe1\xeb\xeb\xdc\xf3\xf3\xe5\xf4\xe1\xe9 \xec\xe5 \xec\xef\xed\xef\xea\xe1\xf4\xef\xe9\xea\xdf\xe1 \xec\xe5 \xea\xde\xf0\xef \xf3\xe5 \xe1\xea\xf4\xdf\xed\xe1 \xec\xdd\xf7\xf1\xe9 30 \xf7\xeb\xec \xe1\xf0\xfc \xc8\xe5\xf3/\xed\xdf\xea\xe7 *527339<P>\r\n\xc5\xd0\xc1\xcd\xd9\xcc\xc7 \xec\xef\xed\xef\xea\xe1\xf4\xef\xe9\xea\xdf\xe1 75\xf4\xec 2\xc4\xd3\xca\xcb \xf3\xe5 \xef\xe9\xea\xef\xf0\xe5\xe4\xef 400\xf4\xec \xea\xe1\xe9 \xca\xe7\xf6\xe9\xf3\xe9\xdc \xe4\xe9\xe1\xec. 74\xf4\xec 12 \xe5\xf4\xfe\xed 1\xef\xf2 \xfc\xf1. 2\xc4\xd3\xca\xcb \xec\xe5 \xe8\xe5\xf1\xec\xef\xf3\xf5\xf3\xf3\xf9\xf1\xe5\xf5\xf4\xdd\xf2 \xe1\xed\xf4\xe1\xeb\xeb\xdc\xf3\xf3\xef\xed\xf4\xe1\xe9 \xec\xe5 2 \xe4\xe9\xe1\xec/\xf4\xe1 \xf3\xf4\xe7 \xc8\xe5\xf3/\xed\xdf\xea\xe7 \xf3\xf4\xe7\xed \xdf\xe4\xe9\xe1 \xf0\xe5\xf1\xe9\xef\xf7\xde \xef\xf0\xef\xf5\xe4\xde\xf0\xef\xf4\xe5 \xe1\xeb\xeb\xef\xfd *431972 \xea\xe1\xe9 *865924<P>\r\n<h2>GIF (from Mosaic-L10N)</h2>\n<img src="greek.html.gif">\n</BODY>\n\n'
>>> print contents #
κινέζικα ....
<HEAD>
<TITLE>Greek / �������� (ISO 8859-7)</TITLE>
</HEAD>
<BODY>
<H1>Greek / �������� (ISO 8859-7)</H1>
<DD> ���� ��
<p>
<a href="http://www.diavlos.gr/agelioforos/k01.htm">
http://www.diavlos.gr/agelioforos/k01.htm</a><p>
<hr>
CITROEN VISA ������������ �� �������� NISSAN *0382/32273<P>
����������� 40 �� ��� ������� ������������� �� ������� 30-40 �� ��� ������ *869544 �������� ��� *287572 ����<P>
����. ��� ������ �� ������� ��� ��������� ����� 27.000.000 ��� ������������� �� ������������ �� ���� �� ������ ����� 30 ��� ��� ���/���� *527339<P>
������� ������������ 75�� 2���� �� �������� 400�� ��� ������� ����. 74�� 12 ���� 1�� ��. 2���� �� ���������������� �������������� �� 2 ����/�� ��� ���/���� ���� ���� ������� ���������� ����� *431972 ��� *865924<P>
<h2>GIF (from Mosaic-L10N)</h2>
<img src="greek.html.gif">
</BODY>
>>> chardet.detect(contents)
{'confidence': 0.87901989033057149, 'encoding': 'ISO-8859-7'} # Ωραία το βρήκε είναι το 'ISO-8859-7'
>>>ToPithanoteroEncoding = chardet.detect(contents)['encoding']
>>> contents.decode(ToPithanoteroEncoding)
u'<HEAD>\n\n<TITLE>Greek / \u0397\u03bb\u03bb\u03ad\u03bd\u03b9\u03ba\u03b1 (ISO 8859-7)</TITLE>\n\n\n\n</HEAD>\n<BODY>\n<H1>Greek / \u0397\u03bb\u03bb\u03ad\u03bd\u03b9\u03ba\u03b1 (ISO 8859-7)</H1>\n<DD> \u0393\u03b5\u03b9\u03ac \u03c3\u03b1\u03c2\n<p>\n<a href="http://www.diavlos.gr/agelioforos/k01.htm">\nhttp://www.diavlos.gr/agelioforos/k01.htm</a><p>\n\n<hr>\nCITROEN VISA \u03b1\u03bd\u03c4\u03b1\u03bb\u03bb\u03ac\u03c3\u03b5\u03c4\u03b1\u03b9 \u03bc\u03b5 \u03b1\u03b3\u03c1\u03bf\u03c4\u03b9\u03ba\u03cc NISSAN *0382/32273<P>\r\n\u0393\u039a\u0391\u03a1\u03a3\u039f\u039d\u0399\u0395\u03a1\u0391 40 \u03c4\u03bc \u03c3\u03c4\u03b7 \u039d\u03b5\u03ac\u03c0\u03bf\u03bb\u03b7 \u03b1\u03bd\u03c4\u03b1\u03bb\u03bb\u03ac\u03c3\u03c3\u03b5\u03c4\u03b1\u03b9 \u03bc\u03b5 \u03b3\u03c1\u03b1\u03c6\u03b5\u03af\u03bf 30-40 \u03c4\u03bc \u03c3\u03c4\u03bf \u03ba\u03ad\u03bd\u03c4\u03c1\u03bf *869544 \u03b1\u03c0\u03cc\u03b3\u03b5\u03c5\u03bc\u03b1 \u03ba\u03b1\u03b9 *287572 \u03c0\u03c1\u03c9\u03af<P>\r\n\u0394\u0399\u0391\u039c. \u03c3\u03c4\u03bf \u03ba\u03ad\u03bd\u03c4\u03c1\u03bf \u03bc\u03b5 \u03b1\u03c3\u03b1\u03bd\u03c3\u03ad\u03c1 \u03ba\u03b1\u03b9 \u03ba\u03b1\u03bb\u03bf\u03c1\u03b9\u03c6\u03ad\u03c1 \u03b1\u03be\u03af\u03b1\u03c2 27.000.000 \u03b4\u03c1\u03c7 \u03b1\u03bd\u03c4\u03b1\u03bb\u03bb\u03ac\u03c3\u03c3\u03b5\u03c4\u03b1\u03b9 \u03bc\u03b5 \u03bc\u03bf\u03bd\u03bf\u03ba\u03b1\u03c4\u03bf\u03b9\u03ba\u03af\u03b1 \u03bc\u03b5 \u03ba\u03ae\u03c0\u03bf \u03c3\u03b5 \u03b1\u03ba\u03c4\u03af\u03bd\u03b1 \u03bc\u03ad\u03c7\u03c1\u03b9 30 \u03c7\u03bb\u03bc \u03b1\u03c0\u03cc \u0398\u03b5\u03c3/\u03bd\u03af\u03ba\u03b7 *527339<P>\r\n\u0395\u03a0\u0391\u039d\u03a9\u039c\u0397 \u03bc\u03bf\u03bd\u03bf\u03ba\u03b1\u03c4\u03bf\u03b9\u03ba\u03af\u03b1 75\u03c4\u03bc 2\u0394\u03a3\u039a\u039b \u03c3\u03b5 \u03bf\u03b9\u03ba\u03bf\u03c0\u03b5\u03b4\u03bf 400\u03c4\u03bc \u03ba\u03b1\u03b9 \u039a\u03b7\u03c6\u03b9\u03c3\u03b9\u03ac \u03b4\u03b9\u03b1\u03bc. 74\u03c4\u03bc 12 \u03b5\u03c4\u03ce\u03bd 1\u03bf\u03c2 \u03cc\u03c1. 2\u0394\u03a3\u039a\u039b \u03bc\u03b5 \u03b8\u03b5\u03c1\u03bc\u03bf\u03c3\u03c5\u03c3\u03c3\u03c9\u03c1\u03b5\u03c5\u03c4\u03ad\u03c2 \u03b1\u03bd\u03c4\u03b1\u03bb\u03bb\u03ac\u03c3\u03c3\u03bf\u03bd\u03c4\u03b1\u03b9 \u03bc\u03b5 2 \u03b4\u03b9\u03b1\u03bc/\u03c4\u03b1 \u03c3\u03c4\u03b7 \u0398\u03b5\u03c3/\u03bd\u03af\u03ba\u03b7 \u03c3\u03c4\u03b7\u03bd \u03af\u03b4\u03b9\u03b1 \u03c0\u03b5\u03c1\u03b9\u03bf\u03c7\u03ae \u03bf\u03c0\u03bf\u03c5\u03b4\u03ae\u03c0\u03bf\u03c4\u03b5 \u03b1\u03bb\u03bb\u03bf\u03cd *431972 \u03ba\u03b1\u03b9 *865924<P>\r\n<h2>GIF (from Mosaic-L10N)</h2>\n<img src="greek.html.gif">\n</BODY>\n\n'
>>> print contents.decode(ToPithanoteroEncoding) # δηλαδή 'iso-8859-7'
<HEAD>
<TITLE>Greek / Ηλλένικα (ISO 8859-7)</TITLE>
</HEAD>
<BODY>
<H1>Greek / Ηλλένικα (ISO 8859-7)</H1>
<DD> Γειά σας
<p>
<a href="http://www.diavlos.gr/agelioforos/k01.htm">
http://www.diavlos.gr/agelioforos/k01.htm</a><p>
<hr>
CITROEN VISA ανταλλάσεται με αγροτικό NISSAN *0382/32273<P>
ΓΚΑΡΣΟΝΙΕΡΑ 40 τμ στη Νεάπολη ανταλλάσσεται με γραφείο 30-40 τμ στο κέντρο *869544 απόγευμα και *287572 πρωί<P>
ΔΙΑΜ. στο κέντρο με ασανσέρ και καλοριφέρ αξίας 27.000.000 δρχ ανταλλάσσεται με μονοκατοικία με κήπο σε ακτίνα μέχρι 30 χλμ από Θεσ/νίκη *527339<P>
ΕΠΑΝΩΜΗ μονοκατοικία 75τμ 2ΔΣΚΛ σε οικοπεδο 400τμ και Κηφισιά διαμ. 74τμ 12 ετών 1ος όρ. 2ΔΣΚΛ με θερμοσυσσωρευτές ανταλλάσσονται με 2 διαμ/τα στη Θεσ/νίκη στην ίδια περιοχή οπουδήποτε αλλού *431972 και *865924<P>
<h2>GIF (from Mosaic-L10N)</h2>
<img src="greek.html.gif">
</BODY>