Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article explains how to get all the URLs that are in confluence pages in bulk using URLs from the Confluence pages based on the regex pattern using the Confluence Command Line Interface (CLI) app.

Instructions

To get Use the runFromPageList and getSource actions to export all the URLs from the Confluence pages to a file using runFromPageList, getSource actions.

The parameters used in the below action are:

  1. space: Name of the space. In this case, @all represents all spaces in 
  2. clearFileBeforeAppend: This option will automatically clear an existing file on the first append requested.
  3. id: ids of pages. In this case, it searches for all the pages in the spaces using @pageId@
  4. file: Path/name to file of result output.
  5. findReplaceRegex: The regex pattern used to match the patterns of the links.

CSV file based on the given parameters. 

  • Execute the below command to get all

...

  • links

...

  • from all pages in all spaces of a

...

  • Confluence instance

...

  • :

    Code Block
    themeMidnight
    --action runFromPageList --space "@all" --clearFileBeforeAppend --common "--action getSource --id @pageId@ --special: "" #"" --append --file spaceLinkList.txt"  --input "--findReplaceRegex ""(?s).*?href=.(http[s]{0,1}://[./a-z]+)#$1,"" --findReplaceRegex ""(?s)(((http[s]{0,1}://[./a-z]+),)*).*#$1"" --findReplaceRegex "",#' \n '"" "


  • Execute the below command to get all the links from a single page of a space:

    Code Block
    themeMidnight
    --action getSource --space "ZCLI" --title "PAGE2" --special " #" --findReplaceRegex "(?s).*?href=\"(http[s]{0,1}://[./a-z]+)#\$1 \n"

...

Results for the above command:
Image Removed

...


The output from the above commands is added to the CSV file is similar to:
Image Added

The parameters used in the actions are:

  • --spaceName of the space. In this case, @all represents all spaces in an instance.
  • --clearFileBeforeAppend: This option automatically clears an existing file on the first append requested.
  • --id: IDs of pages. In this case, it searches for all the pages in the spaces using @pageId@.
  • --filePath/name to file of result output.
  • --findReplaceRegex: The regex pattern used to match the patterns of the links.
  • --special: Characters used for specialized processing of some specific parameters.
  • --append: The option appends output to the existing file.


Info
  • The above action is available from CLI v9.3 and above. 
  • Make sure the regex pattern matches the pattern of the page links to get meaningful output.
  • The above command will work for the windows commands work on a Windows machine. Make sure you update the quotes syntax accordingly for Linux based machines.