How do I get the pure HTML content from confluence pages?

Asif Bhat September 27, 2024

Hi

I would like to get the content from pages but in HTML. I used this api 

 

https://<*>.atlassian.net/wiki/rest/api/content/{id}?expand=body.storage

but it won't give the pure html. It contains elements like "
ac:structured-macro ac:name" etc

Thanks

2 answers

0 votes
Camilo Galleguillos
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2024

Hi, @Asif Bhat, welcome to the Atlassian Community!

One way to get the actually rendered HTML code of the page is to access the developer console of your browser, and from there look for the id="main-content" element. You could copy it and paste it wherever you need it.

Another option, which would work for multiple pages, is to run a space export in HTML format. You can find it in the space settings, and it will allow you to choose the pages you'd like to include in the export. Just note that the styles in the exported files may look different.

Best,

cgr-sr-badge

Camilo Galleguillos

Sr. Technical Consultant

ServiceRocket
camilo.galleguillos@servicerocket.com
Santiago, Chile

0 votes
Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2024

Hello @Asif Bhat !

You can use ?expand=body.view. This will get the HTML view representation of the page body.

Asif Bhat September 27, 2024

I tried it. Not much dufference. It uses confluence class ids. Is there any way to get the style sheets?

Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2024

The difference is that Storage is XML (xHTML) Confluence format and View is HTML format. I did not see in the question Information the stylesheets. You can try also other options for body representation in the REST documentation.

If your task is to get the full HTML and CSS/JS resources,  you can find them in AUI, Atlaskit documentation that gives fill overview on the CDN resources you need to implement look and feel as in Confluence.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events