Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need and have to create a script that takes webpage address and time in seconds as arguments. It records whatever is shown on the webpage - i.e. JavaScript and HTML content (Flash not required). Script is going to be run non-interactively as a cron job. Other constraints are that it can not start a login manager or hijack an already running X server. Also can not assume that a login manager is installed or what kind of graphics adapter is built into the server. This semi-solution is what I came up with so far, but it's not good because of the Xserver and because it need to be run as cron job. Also it needs to be run on latest Ubuntu or Debian!

If you have any other workarounds or suggestions, just say! :)

if [ $# -ne 3 ]then
echo "Arguments missing!";
echo "Entered  : $0 $1 $2 $3 (out of $# vars)";
echo "Should be: $0 http://feri.uni-mb.si/ 60s i_stare_at_websites_everyday.ogv";
exit
fi

#continued...
URL=$1;
TIME=$2;
OUTFILE=$3;

echo "++ Using URL: $URL";
echo "++ Capturing browser window for $TIME seconds";

# chromium is used as a better workaround for firefox's safe mode PITA browser.jar settings unpack+set+pack bug
#firefox $1 &
chromium-browser --disable-translate --app=$URL --user-data-dir /tmp &
browserPID=$!
#sleep for 4 secodns = loading firefox + webpage loading time 2+2?
#recordmydesktop has a delay argument which doesn't work.
#we need to sleep the execution old school way.
sleep 4s

unset xC yC wC hC
  eval $(xwininfo -id $(xdotool getactivewindow) |
    sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/xC=\1/p" \
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/yC=\1/p" \
           -e "s/^ \+Width: \+\([0-9]\+\).*/wC=\1/p" \
           -e "s/^ \+Height: \+\([0-9]\+\).*/hC=\1/p" )

echo "Starting capture...";
recordmydesktop -x=$xC -y=$yC --width=$wC --height=$hC -o $OUTFILE 2&> /tmp/record_script_log &
# 2&> /tmp/recording_script.log &
recorderPID=$!
echo "++ Firefox Process ID: $firefoxPID, RCD ID: $recorderPID, Recording for: $TIME";
sleep $TIME
echo "++ All done! Cleaning up..."
echo "++ File saved as $OUTFILE";
# shut down "record my desktop" nicely
kill $recorderPID
kill -9 $browserPID
share|improve this question
1  
do you want to use wget? –  don.joey Mar 14 '13 at 13:54

1 Answer 1

Use wget. It should be installed on your system because it is a dependency of the ubuntu-standard package. Otherwise install it with apt-get install wget.

share|improve this answer
    
I need the script create a video. It seems to me that wget downloads only content, am I right? –  Nooich Mar 14 '13 at 14:48
    
@Nooich Your question doesn't mention creating a video. I suggest you update it to explicitly state what you want the output to be: animated GIF? Just to be clear: if you open the output of the wget command, you will actually see pretty much what you would have seen in a browser. –  zwets Mar 14 '13 at 17:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.