python - How to run a script from GEANY (win 7)? -


please me sort out.

i have run following script idle (win7):

import requests import lxml.html  def get_doc(url):     try:         req = requests.get(url)     except requests.exceptions.connectionerror exc:         print('a connection error occurred. _____ ', exc)     else:         return req   if __name__ == "__main__":     baseurl = 'http://en.modagram.com/'     #baseurl = 'http://forum.saransk.ru/'      req = get_doc(baseurl)     doc_html = req.text     print(doc_html)     doc_obj = lxml.html.document_fromstring(doc_html) 

as result, script writes html page.

i have run script same geany (win7). result following error message

traceback (most recent call last): file "index.py", line 19, in print(doc_html) file "c:\python33\lib\encodings\cp866.py", l return codecs.charmap_encode(input,self.er unicodeencodeerror: 'charmap' codec can't enco 92: character maps

please tell me how run script geany?

as error suggests, when print doc_html, python tries convert charmap encoding fails.

try instead :

print(doc_html.decode('charmap')) 

if doesn't work (which think case), try this:

print(doc_html.decode('charmap', errors='ignore')) 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -