Skip to content

Instantly share code, notes, and snippets.

@CDanU
Last active August 6, 2023 01:13
Show Gist options
  • Save CDanU/38414e4014b483b562115427f4e3f05c to your computer and use it in GitHub Desktop.
Save CDanU/38414e4014b483b562115427f4e3f05c to your computer and use it in GitHub Desktop.
Combine all messages.*.html files into one, uses pup to extract html elements
#!/bin/bash
HTML_SELECTOR=".message"
for FILE in $(ls -1v messages*); do
cat ${FILE} | pup ${HTML_SELECTOR} >> data.html;
done
DATA=$(cat data.html); eval "cat <<EOF
$(<template.html)
EOF
" > all.html
rm data.html
src: https://stackoverflow.com/a/12422379
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Exported Data</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<link href="css/style.css" rel="stylesheet"/>
<script src="js/script.js" type="text/javascript">
</script>
</head>
<body onload="CheckLocation();">
<div class="page_wrap">
<div class="page_header">
<div class="content">
<div class="text bold">
[NAME]
</div>
</div>
</div>
<div class="page_body chat_page">
<div class="history">
${DATA}
</div>
</div>
</div>
</body>
</html>
@CDanU
Copy link
Author

CDanU commented Aug 6, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment