python - export_media from Google Drive API don't write newlines -


when try export text google docs using export_media method, result bloc of text (correct @ least) without newlines.

for exemple, if file contains

test

and test

the display looks like

test , test

here code:

http = decorator.http() service = discovery.build("drive", "v2", http=http) docs = service.files().export_media(fileid=docs_key, mimetype="text/plain").execute() docs = docs.decode('utf-8') 

edit:

i tried export file html content instead of text. problem don't how use html actual html instead of string. here code :

http = decorator.http() service = discovery.build("drive", "v2", http=http) docs = service.files().export_media(fileid=docs_key, mimetype="text/html").execute()  docs = docs.decode('utf-8') docs = docs.encode('ascii', 'xmlcharrefreplace') h = htmlparser() docs = h.unescape(docs) 

as can see, docs contains google document in html format. if try display docs this, web page display time html code (still without newlines) :

<html><head><meta content="text/html; charset=utf-8" http-equiv="content-type"><style type="text/css"> ul.lst-kix_yreqa03lukup-0{list-style-type:none}.lst-kix_yreqa03lukup-3 > li:before{content:"❏ "}.lst-kix_yreqa03lukup-4 > li:before{content:"❏ "}ul.lst-kix_yreqa03lukup-2{list-style-type:none}ul.lst-kix_yreqa03lukup-1{list-style-type:none}.lst-kix_yreqa03lukup-5 > li:before{content:"❏ "}.lst-kix_yreqa03lukup-1 > li:before{content:"❏ "}.lst-kix_yreqa03lukup-7 > li:before{content:"❏ "}.lst-kix_yreqa03lukup-0 > li:before{content:"✓ "}.lst-kix_yreqa03lukup-6 > li:before{content:"❏ "}.lst-kix_yreqa03lukup-8 > li:before{content:"❏ "}ul.lst-kix_yreqa03lukup-8{list-style-type:none}ul.lst-kix_yreqa03lukup-7{list-style-type:none}ul.lst-kix_yreqa03lukup-4{list-style-type:none}.lst-kix_yreqa03lukup-2 > li:before{content:"❏ "}ul.lst-kix_yreqa03lukup-3{list-style-type:none}ul.lst-kix_yreqa03lukup-6{list-style-type:none}ul.lst-kix_yreqa03lukup-5{list-style-type:none}</style></head><body style="background-color:#ffffff;padding:72pt 72pt 72pt 72pt;max-width:451.3pt"><p style="padding:0;margin:0;color:#000000;font-size:11pt;font-family:"arial";orphans:2;widows:2"><span>first online edit : 15h50</span></p></body></html> 

of course, want display generate html webpage, , not string it's showing.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -