简体   繁体   中英

Object of type 'BeautifulSoup' is not JSON serializable

I am trying to load html content to confluence page .I am trying to use BeautifulSoup pkg to achieve this . In that process i am getting below error. is there any way to resolve these issue or any other appraoch to achieve this task.

TypeError: Object of type 'BeautifulSoup' is not JSON serializable

below is the content of html file

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.
  <br>This is going < ,= to print
This is going >  to print</br>

code:

import yaml
from atlassian import Confluence
import urllib, mimetypes
import  requests
import codecs,json

confluence = Confluence(
    url='https://confluence.com',
    username='12344',  # of system where this page would open
    password='abcd')

####reading HTML file
with open("sample.html", 'r')as f
content = f.read()

soup = BeautifulSoup(content, 'html.parser')


# Create page from scratch
status = confluence.create_page('ABCD' ,#space,
                       'Report',#title
                        soup ,#'This is the body',#body,
                       parent_id=123456,### this is the pageid of the page under which new page will be created
                       type='page',
                       representation='storage',
                       editor='v2')

print(status)
status = confluence.create_page('ABCD' ,#space,
                       'Report',#title
                        soup ,#'This is the body',#body,
                       parent_id=123456,### this is the pageid of the page under which new page will be created
                       type='page',
                       representation='editor')

using this we can achieve this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM