Start KRAD Sample App. Then run the following shell script.
bash static-krad-sampleapp.sh
| #!/bin/sh | |
| # | |
| # http://www.gnu.org/software/wget/manual/wget.html | |
| # | |
| # -m --mirror | |
| # -p --page-requisites (page dependencies) | |
| # -k --convert-links (change references) | |
| # -E --adjust-extension (add .html, etc) | |
| # -O --output-document=file | |
| # -P --directory-prefix=prefix | |
| # -a --append-output=logfile | |
| # -o --output-file=logfile (overwrite log) | |
| # Download the login page. | |
| #wget -O login.html http://localhost:8080/krad-dev/ | |
| wget --save-cookies cookies.txt --keep-session-cookies -O login.html http://localhost:8080/krad-dev/ | |
| # Extract the hidden form data and transform them into URL parameters. | |
| hiddenData=`grep value < login.html | grep -v script | grep -v login_user | tr '=' ' ' | awk '{print $5"="$7}' | sed s/\"//g | tr '\n' '&'` | |
| # Remove the login page. | |
| rm login.html | |
| # Add the login credentials. | |
| postData=login_user=admin'&'${hiddenData} | |
| # Send the post data, login, and mirror the site. | |
| wget --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies -m -p -k -E --post-data ${postData} http://localhost:8080/krad-dev/kr-login/login | |
| echo $postData |
Inspired from these solutions:
Wget 1.15 Manual