Today I was showning someone my old Blogger website and one of the reasons I moved away from blogger is that it was hard to edit and did not work well with my workflow. It occured to me that it may be easy to migrate from Blogger to my new Pelican Blog.
STEP 1: Download Blog's Atom Feed¶
First thing I noticed is the atom link at the bottom of the page. I right clicked on the feed and saved it as a file called "Family_Making.xml".
STEP 2: Find, install and test atom parser for python¶
I then googled aroud for a atom feed parser in Python. Came up with feedparser
pip install feedparser
The following verified that feedparser was working
d = feedparser.parse('./Family_making.xml')
After looking at the entries I realized that i needed the
'Ultimaker 2, cleaning a clogged nozzle'
STEP 3: Convert xlm/html and save as a markdown file suitable for pelican¶
Notice that the
summary field was stored as HTML instead of markdown. Another quick google lead me to html2text. Either I have already pip installed this library or it came with my anaconda installtion. In either case it loaded just fine.
The following function takes an entriy in the atom feed and converts it to markdown format.
#Stub function. Does nothing. I added this later (see below) def geturls(s, makelocal=True): return s
def parseentry(e, save=False, show=True): date = e.published[0:10] title = e.title filename = date.replace('-','')+"_"+e.title.replace(' ','_')+'.md' url = e.link s='Title: '+title+'\n' s+='Date: '+date+'\n' s+='Tags: Maker, 3DPrinting\n' s+='\n' s+=geturls(html2text.html2text(e.summary))#, makelocal=not(show)) s+='Blogpost migrated from [Blogger]('+url+') using costom python script. Comment on errors below.\n' if save: print('Saving: '+filename) f=open(filename,'w') f.write(s) f.close() if show: print(filename) print(s) return s
Lets test it here...
s = parseentry(d.entries)
20150509_Intrducing_a_3D_printer_to_my_daughter's_Kindergarten_class.md Title: Intrducing a 3D printer to my daughter's Kindergarten class Date: 2015-05-09 Tags: Maker, 3DPrinting We had fun showing off my 3D printer to the Kindergarten class. Although the printer is fun to watch, kids tend to get board with it in just a few minutes. I like to come up with classroom projects that let the kids use things that are printed with the printer. Since it is so cheep it is also fun to print something ahead of time that they can take home. For the kindergarten class we printed some flowers that the kids could use to put together a cut spring time flower pots just in time for mother's day: [!(http://4.bp.blogspot.com/-CiJUKjlzqcY/VU6KF04S50I/AAAAAAAADYk/kRUWF98Binc/s320/Photo%2BMay%2B09%2C%2B3%2B04%2B38%2BPM.jpg)](http://4.bp.blogspot.com/-CiJUKjlzqcY/VU6KF04S50I/AAAAAAAADYk/kRUWF98Binc/s1600/Photo%2BMay%2B09%2C%2B3%2B04%2B38%2BPM.jpg) It even lights up: [!(http://1.bp.blogspot.com/-pBFgujkY9q8/VU6KFhrAYMI/AAAAAAAADYg/tZphITf-J0E/s320/Photo%2BMay%2B09%2C%2B3%2B04%2B45%2BPM.jpg)](http://1.bp.blogspot.com/-pBFgujkY9q8/VU6KFhrAYMI/AAAAAAAADYg/tZphITf-J0E/s1600/Photo%2BMay%2B09%2C%2B3%2B04%2B45%2BPM.jpg) The kids had a great time. Here are some pictures [!(http://4.bp.blogspot.com/-HrERuNuZZu4/VU6K7pHoUqI/AAAAAAAADY4/-8WReCBw-eY/s320/Photo%2BMay%2B06%2C%2B1%2B52%2B01%2BPM.jpg)](http://4.bp.blogspot.com/-HrERuNuZZu4/VU6K7pHoUqI/AAAAAAAADY4/-8WReCBw-eY/s1600/Photo%2BMay%2B06%2C%2B1%2B52%2B01%2BPM.jpg) [!(http://3.bp.blogspot.com/-Isq8v7xffYc/VU6K6jtRtUI/AAAAAAAADYw/ptVsHZlos9M/s320/Photo%2BMay%2B06%2C%2B1%2B52%2B16%2BPM.jpg)](http://3.bp.blogspot.com/-Isq8v7xffYc/VU6K6jtRtUI/AAAAAAAADYw/ptVsHZlos9M/s1600/Photo%2BMay%2B06%2C%2B1%2B52%2B16%2BPM.jpg) [!(http://3.bp.blogspot.com/-Q5yEH7AheOs/VU6LRFo0ShI/AAAAAAAADZQ/UgQCa5xUQYM/s320/Photo%2BMay%2B06%2C%2B1%2B52%2B39%2BPM.jpg)](http://3.bp.blogspot.com/-Q5yEH7AheOs/VU6LRFo0ShI/AAAAAAAADZQ/UgQCa5xUQYM/s1600/Photo%2BMay%2B06%2C%2B1%2B52%2B39%2BPM.jpg) [!(http://3.bp.blogspot.com/-2Wo_OvPVJxk/VU6K8cnn4sI/AAAAAAAADZA/OZIqA22-G0U/s320/Photo%2BMay%2B06%2C%2B1%2B03%2B20%2BPM.jpg)](http://3.bp.blogspot.com/-2Wo_OvPVJxk/VU6K8cnn4sI/AAAAAAAADZA/OZIqA22-G0U/s1600/Photo%2BMay%2B06%2C%2B1%2B03%2B20%2BPM.jpg) Turned out to be a lot of fun. If you are interested in makeing your own here is a list of instructions on Instructables: <http://www.instructables.com/id/Spring-kindergarten-Class-Project-with-3D-Printer/> And the 3D files on YouMagine: <https://www.youmagine.com/designs/light-up-flower> Blogpost migrated from [Blogger](https://apprenticemaker.blogspot.com/2015/05/showing-off-3d-printer-to-daughters.html) using costom python script. Comment on errors below.
Now lets run though all of the entires and save them...
for e in d.entries: parseentry(e, save=False, show=False)
I notieced that there are a lot of minor errors in my posts (spelling, tags,? etc). There also seems to be a problem with URLs with dashes (
-) where the file seems to add a charage return. Not sure why. I tried fixing it with a program but realized I have to read and verify each entry anyway so I will just fix them by hand.
Overall the entire project took me less than 40 minutes sitting at the airport (including writing this post) :-)
I got board on the plane so I thought I would try to write a program to download the pictures. This also fixes a weird problem with my URLs.
from urllib.request import urlopen, urlretrieve def geturls(s, makelocal=False): pictures=s.split('!(') imageurls =  urls= if pictures: for p in pictures: if(p[0:4] == 'http'): url_list = p.split(')') url1_old = url_list url1_new = url1_old.replace('\n','') filename = url1_new.split('/')[-1] if(makelocal): fullpath='./images/'+filename print('saving '+fullpath) urlretrieve(url1_new, fullpath); url1_new = fullpath imageurls.append(url1_new) url2_old = url_list.split('()') url2_new = url2_old.replace('\n','') if(makelocal): url2_new = '](../images/'+filename s = s.replace(url1_old,url1_new) s = s.replace(url2_old,url2_new) refs = s.split('<http') refs = refs[1:] for r in refs: url = r.split('>') url2 = url.replace('\n','') s = s.replace(url,url2) return s
I have been having trouble with my 3D printer over the last couple of months. It turns out that the fans got disconnected. Once I fixed the problem my printer is working better than ever. I was itching for something to print so I came up with this simple spacer. [!(https://lh3.googleusercontent.com/-9lxv9eHP0vE/VQ8m4AV34dI/AAAAAAAADUk/UluX9uZIpx4/s320/blogger-image--470762115.jpg)](https://lh3.googleusercontent.com/-9lxv9eHP0vE/VQ8m4AV34dI/AAAAAAAADUk/UluX9uZIpx4/s640/blogger-image--470762115.jpg) I installed a motion sensor in my basement because the light switch is in an inconvenient place and most of the time we go in this part of the basement my hands seem to be full. The motion sensor fixes this problem and even found a outlet plate on thingiverse that fit perfectly. <http://www.thingiverse.com/thing:457658> The only problem is that the installed switch box is too small for the new sensor and my printed play sticks out a good 15 mm from the box. [!(https://lh4.googleusercontent.com/-fWMqokmTHSY/VRALGk8pElI/AAAAAAAADVE/KYj6aiG8kEY/s640/blogger-image-2136501427.jpg)](https://lh4.googleusercontent.com/-fWMqokmTHSY/VRALGk8pElI/AAAAAAAADVE/KYj6aiG8kEY/s640/blogger-image-2136501427.jpg) A few minutes with OpenScad and a two hour print later I have a nice looking solution. [!(https://lh5.googleusercontent.com/-UziobC6p1aU/VRALHqt6kuI/AAAAAAAADVM/Umb587yQAwQ/s640/blogger-image--906009313.jpg)](https://lh5.googleusercontent.com/-UziobC6p1aU/VRALHqt6kuI/AAAAAAAADVM/Umb587yQAwQ/s640/blogger-image--906009313.jpg) Here is a link to the OpenSCAD file if you are interested in printing your own: <https://www.youmagine.com/designs/wall-switch-spacer> Easy and fun! Nice to have my printer back! \- Dirk
Commit Early and Often
Ugh! Rookie mistake! I just spent all morning working on my website and blog. I was really happy with the improvements. I was making some modifications to the Makefile in the pelican folder to streamline my workflow when... all of my files disappeared.
Rookie Mistake #1: I unintentionally did a …read more