I'm looking for the best approach to import a couple dozen articles written in Google Docs. Just need to be pointed in the right direction.
You could mount your Google Drive with xmldirector.plonecore and a 3rd-party SaaS bridge like otixo.com or storagemadeeasy.com into Plone and write some Python script to access the data from Google Drive within Plone and copying them to File instances.
-aj
1 Like
@zopyx,
Thanks for the idea. I decided to just drop them as HTML files to the filesystem then use a python script with beautifulsoup4 to extract the body.
Something like this is my starting point, but still a work in progress:
(some of the stuff here is still hardcoded, so this is just a starting point, note the use of RichTextValue, because the text is stored as richtext)
from plone import api
from bs4 import BeautifulSoup
from plone.app.textfield.value import RichTextValue
def import_html(self, folder):
path = "%s/*.html" % folder
files = glob.glob(path)
for file in files:
f = open(file, 'r')
html_content = f.read()
soup = BeautifulSoup(html_content, 'html.parser')
obj = api.content.create(
type='document', # set the content type
container=self.context,
title="just a test",
text=RichTextValue(soup.body, 'text/plain', 'text/html')
)
f.close()