<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def handle(self, *args, **options):
 """gets data from WordPress site"""

        # TODO: refactor these with .get
        if 'username' in options:
            self.username = options['username']
        else:
            self.username = None
        if 'password' in options:
            self.password = options['password']
        else:
            self.password = None

        self.xml_path = options.get('xml')
        self.url = options.get('url')
        try:
            blog_index = BlogIndexPage.objects.get(
                title__icontains=options['blog_index'])
        except BlogIndexPage.DoesNotExist:
            raise CommandError("Incorrect blog index title - have you created it?")
        if self.url == "just_testing":
            with open('test-data.json') as test_json:
                posts = json.load(test_json)
        elif self.xml_path:
            try:
                import lxml
                from blog.wp_xml_parser import XML_parser
            except ImportError as e:
                print("You must have lxml installed to run xml imports."
                      " Run `pip install lxml`.")
                raise e
            self.xml_parser = XML_parser(self.xml_path)
            posts = self.xml_parser.get_posts_data()
        else:
            posts = self.get_posts_data(self.url)
        self.should_import_comments = options.get('import_comments')
        self.create_blog_pages(posts, blog_index)