Skip navigation.

My pasteblog

This is not my Zettelkasten but a durable .bash_history

Posts tagged with "wget"

Archiving eBay auctions with wget, input from textfile parsed with awk

, , , ...

#!/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
December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31