WordPress to micolog Conversion Tool

Source: Internet
Author: User
Tags bmp image

Although micolog provides the ability to import logs from WordPress files, the conversion from Wordpress to micolog is not so perfect. In simple terms, there are two manifestations:

1. If the item contains <title> *******. jpg </title>, import the automatic middle section. I don't know why the XML file exported by WordPress contains such a strange content, not logs.

2. Images cannot be imported. What if you migrate logs from Wordpress to micolog? You can either upload a static file to Gae and create a corresponding path. However, if there are too many files, you will be worried about exceeding the limit of 1000 files. The best way is to import all images to the Gae database in the micolog format.

Today we will solve these two problems. According to my needs, I wrote a piece of code using python. After running the code, I can import Wordpress to micolog perfectly. Let's talk about the specific operations and then the principles. The procedure is as follows:

0. Back up all your WordPress files to your local device (this tool mainly uses uploaded files ). Go to the WordPress background and export all logs as WordPress. xml. These two are needed later, so please finish processing before you start.

1. Edit the app. yaml file and configure the remote_api path as follows: (the specific path can be modified by yourself ). (Of course, The micolog upload is also included here. Please solve it by yourself. If you have uploaded micolog, initialize the data, in the database, all data except the blog data will be deleted .)

-URL:/remote_api
Script: $ python_lib/Google/appengine/EXT/remote_api/handler. py
Login: Admin

2. Download The wordpress2micolog. py file and edit several parameters in the file as your own parameters:

# This is an applicationProgramID
App_id = 'myappid'
# If it is local processing, change the host to your own URL path. If it is processed directly on appengine, use appspot.com
Host = '127. 0.0.1: 127'
# Host = '% s.appspot.com' % app_id
# Remote_api path
Remoteurl = '/remote_api'
# Original WordPress URL
Wpurl = 'HTTP: // developer.sharesh.cn'
# Local WordPress path
Wppath = 'e: \ phpnow \ htdocs \ blog'
# WordPress. xml file directory
Xmlpath = 'e: \ phpnow \ htdocs \ blog'

3. Run the wordpress2micolog. py file (we recommend that you use the idle that comes with python2.5 to run it. If there is an error, you can see the specific problem. This step mainly uploads all images and generates the micolog. xml file based on the WordPress. xml file. The image path in the micolog. xml file is already the micolog path.

4. Go to the micolog background, import the file, select the generated micolog. xml file, and import it directly. We recommend that you use Firefox instead of IE to import data. If there is an interruption in the process, the Gae times out and is in micolog. find the item of the last imported record in the XML file, delete all the catalog, tag, and imported item items, leave the unimported item project, save the file, and import again, it will be done. We recommend that you re-create the micolog tool.ArticleLink.

Let's talk about the ideas below:

After reading the entire process, I basically understood my ideas. In fact, the important thing is wordpress2micolog. py. What is the role of this file? Three main tasks are completed: 1. Delete unnecessary item items in the XML file to ensure that the uploaded items are correct in micolog; 2. According to IMG and A in the XML file, upload All images to the database. 3. Modify the img src and a href paths in the XML file based on the uploaded images.

So I divided it into two functions. The first function is Wordpress to a temporary file. It deletes invalid items and uploads all images to the database, the second function is to generate a new valid image link based on the images in the database and generate an XML file.

However, there is also a problem with the tool. Because I do not have PNG or BMP image formats, I only judge JPG files and only JPG files in item judgment, when uploaded to the database, the type is directly defined as image/JPEG. In addition, the name in the database is set to the original image URL, rather than the JPG name. In general, this does not affect your situation. If your situation is special, followCodeYou can modify it by yourself.

By the way, I tested the micolog WordPress export function and found that WordPress can be used completely. However, like wordpress2micolog, Images cannot be directly downloaded and updated. It seems that if I export micolog to WordPress in the future, you also need to write another tool, my God.

I haven't published any logs. I wrote the previous one to fill the count. The py code is a good dish. If you see that python I wrote is funny, Please give some advice, but it took me a lot of time to make me such a dish, so I lament that writing code is really a painful thing.

Finally, let's take a look at the test results. We will provide you with reference: WordPress. xml: 1.75 m; post: 144; JPG file: 799; micolog. xml: 486 K. It takes about several minutes to pass the local test. The process of formally uploading to Gae failed several times, but fortunately I divided it into two functions, so if the function of temp2micolog fails after the function of wp2temp is completed, comment out the function of wp2temp and let it directly enter the function of temp2micolog. It should be noted that if the function of wp2temp fails in the middle, you must delete all the images in the database. However, after the function is deleted, you do not know why the database remains small and depressing, I will try again next time, but it also seems that my program still needs to be improved. At least it can be resumed. The final test result is: it takes 40 minutes to upload 799 images and 60 minutes to rewrite micolog. xml. It took a total of 100 minutes to make people dizzy. It seems that it really needs to be improved.

Last: Thanks to Step 1

: Http://files.cnblogs.com/Tangf/WordPress2Micolog.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.