Archiving eBay auctions with wget, input from textfile parsed with awk
Sunday, 26. February 2006, 10:48:39
#!/bin/bash
awk -F"\t" '
function makeEasyAccess()
{
system("mv " $1 "/cgi.ebay.de/ws/*html " $1 "/cgi.ebay.de/ws/index.html")
system("sed s~##path##~cgi.ebay.de/ws/index.html~ index.html.tpl > " $1 "/index.html")
}
function conditionalFetch()
{
#http://www.unix.org.ua/orelly/unix/sedawk/ch10_03.htm
if (system("test -r " $1 )) {
print "\t not mirrored, fetching..."
system(command)
makeEasyAccess()
}
else print "\t already mirrored"
}
{
URL="cgi.ebay.de%2Fws%2FeBayISAPI.dll%3FViewItem%26item" "=" $1
command = ("/usr/bin/wget --quiet -P " $1 " -F -E -H -k -K -p http://" URL)
if ( $2 !~ /^shop$/ ) {
ebayEndtime = mktime ( 20 substr($2,7,2) " " substr($2,4,2) " " substr($2,1,2) " " substr($2,10,2) " " substr($2,13,2) " " substr($2,16,2) )
if ( ebayEndtime < systime()) {
print $1 ": ebayEndtime is in past"
conditionalFetch()
}
else print $1 ": ebayEndtime is in future"
}
else {
print $1 ": is a shop offer"
conditionalFetch()
}
}' Id_Endtime.txt
The input format is a plain tab-delimeted file with the end time in german format. Other formats need to adjust the above line "ebayEndtime = mktime ( 20 substr($2,7,2) " " substr($2,4,2) " " substr($2,1,2) " " substr($2,10,2) " " substr($2,13,2) " " substr($2,16,2) )"
7392197359 26.02.06 23:51:14 MEZ 7391483206 27.02.06 07:46:37 MEZ 7391548097 27.02.06 20:03:00 MEZ 7387433771 28.02.06 21:30:00 MEZ 6607816962 01.03.06 20:45:00 MEZ 7392366671 02.03.06 16:06:06 MEZ 6608401423 06.03.06 20:35:00 MEZ 7326030533 shop 7351499282 shop 7393652292 07.03.06 19:15:00 MEZ

