The Unicode conversion issue.. [UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 10-15: ordinal not in range(128)]

>>>site= pywikibot.Site(‘en’,’wikipedia’)
>>> cat = {
…     ‘ar’: u’تصنيف:وسوم حقوق نسخ الصور غير الحرة’,
…     ‘en’: u’Category:Wikipedia non-free file copyright tags’,
…     ‘zh’: u’Category:合理使用图像模板’,
… }
>>> category = pywikibot.translate(site, cat)
>>> templatecat = pywikibot.Category(site, category)
>>> templatelist = list(templatecat.articles())
>>> for template in templatelist:
…     temp = pagegenerators.ReferringPageGenerator(template)
…     print list(temp)
>>>
ending in :
 Page(Wikipedia:WikiProject Chile/Assessment), Page(Wikipedia:WikiProject Rhode Island/Assessment), Page(Wikipedia:WikiProject Green Day/Assessment), Page(Wikipedia:WikiProject Polynesia/Assessment), Page(Wikipedia:WikiProject Wisconsin/Assessment), Traceback (most recent call last):
  File “<stdin>”, line 3, in <module>
UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 27-28: ordinal not in range(128)
and for another case:
>>> c = site.newpages(step=100)
>>> list(c)
ending in :
(Page(No Sections test), u’2015-04-16T15:41:01Z’, 36, u”, u’72.28.152.40′, u’Created page with “This is an article without sections.”‘), (Page(Wikipedia:Requests for permissions/Pending changes reviewer), u’2015-04-16T05:01:14Z’, 1915, u”, u’MusikAnimal’, u’Created page with “<noinclude>{{pp-semi-indef}}{{pp-move-indef}}{{Requests for permissions}}{{noadminbacklog}}<!–If the backlog is cleared, than change this to {{noadminbacklog}} and vice-versa…”‘), (Page(User:Joylintp), u’2015-04-16T01:52:51Z’, 520, u”, u’Joylintp’, u’Created page with ” ==\u554f\u5019== ===\u4e2d\u6587=== \u60a8\u597d!\u6b61\u8fce! ===English=== Hello!Welcome ! ===\u65e5\u672c\u8a9e=== \u3053\u3093\u306b\u3061\u306f\uff01\u3088\u3046\u3053\u305d\uff01 ===esperanta=== Saluton!Bonvenon ! ===fran\xe7ais=== Bonj…”‘), (Traceback (most recent call last):
  File “<stdin>”, line 1, in <module>
UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 10-15: ordinal not in range(128)
Advertisements