Coder Social home page Coder Social logo

wpparser's Introduction

Build Status PyPI version

wpparser

This library parses Wordpress xml based exports into a simple python dictionary.

How it works

The library uses ElementTree to traverse through the export file.

Usage

import wpparser

data = wpparser.parse("./blog.wordpress.2014-09-26.xml")
>>> {"blog": {"tagline": "Tagline",...

What it returns

It returns a well formatted dict, containing the following datatypes:

  • Blog: The general blog information, such as tagline, site url.
  • Authors: A list with the different authors.
  • Categories: The categories in use, organized as a nested array.
  • Tags: A list with the different tags.
  • Posts: An array that contains all posts, the post object might also contain the different comments belonging to the post.

Example:

{
    "blog": {
        "tagline": "Tagline",
        "site_url": "http://marteinn.se/blog",
        "blog_url": "http://marteinn.se/blog",
        "language": "en-US",
        "title": "Marteinn / Blog"
    },
    "authors: [{
        "login": "admin",
        "last_name": None,
        "display_name": "admin",
        "email": "[email protected]",
        "first_name": None}
    ],
    "categories": [{
        "parent": None,
        "term_id": "3",
        "name": "Action Script",
        "nicename": "action-script",
        "children": [{
            "parent": "action-script",
            "term_id": "20",
            "name": "Flash related",
            "nicename": "flash-related",
            "children": []
        }]
    }],
    "tags": [{
        "term_id": "1",
        "slug": "bash",
        "name": "Bash"
    }],
    "posts": [{
        "creator": "admin",
        "excerpt": None,
        "post_date_gmt": "2014-09-22 20:10:40",
        "post_date": "2014-09-22 21:10:40",
        "post_type": "post",
        "menu_order": "0",
        "guid": "http://marteinn.se/blog/?p=828",
        "title": "Post Title",
        "comments": [{
            "date_gmt": "2014-09-24 23:08:31",
            "parent": "0",
            "date": "2014-09-25 00:08:31",
            "id": "85929",
            "user_id": "0",
            "author": u"Author",
            "author_email": None,
            "author_ip": "111.111.111.111",
            "approved": "1",
            "content": u"Comment title",
            "author_url": "http://example.com",
            "type": "pingback"
        }],
        "content": "Text",
        "post_parent": "0",
        "post_password": None,
        "status": "publish",
        "description": None,
        "tags": ["tag"],
        "ping_status": "open",
        "post_id": "1",
        "link": "http://www.marteinn.se/blog/slug/",
        "pub_date": "Mon, 22 Sep 2014 20:10:40 +0000",
        "categories": ["category"],
        "is_sticky": "0",
        "post_name": "slug"
    }]
}

Installation

wpparser can easily be installed through pip.

$ pip install wpparser

Contributing

Want to contribute? Awesome. Just send a pull request.

License

wpparser is released under the MIT License.

wpparser's People

Contributors

k0ng avatar marteinn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.