Updated 2015-09-13 17:47:48 by RLE

male - 2006-01-18:

I missed the possibility to preorder every product found at http://www.amazon.de, so I took a look at the URL of a product page and the URL provided by a button called "preorder" and created a small tool to built a preorder url out of the product URL.

The background is, that every product, that is already available as secondhand product, can not be "preordered" (ordered in advance), because Amazon.de does not provide the button with the necessary URL for it.

With this tool you have the possibility to "preorder" mostly every product, as long Amazon doesn't stop it, by specifying the quality and the price to buy for the wanted secondhand product!

Here the code:
 proc preorder {} {
    global productUrl preOrderUrl;
    if {[regexp -- {^http://www.amazon.de/exec/obidos/ASIN/(\w{10})/[^/]+/(\d{3}-\d{7}-\d{7})} $productUrl => ref1 ref2] != 1} {
       tk_messageBox \
          -parent  . \
          -icon    error \
          -type    okcancel \
          -title   "invalid product URL" \
          -message "Couldn't extract necessary information from the probably invalid product URL!";
    set preOrderUrl "http://www.amazon.de/exec/obidos/redirect-to-external-url/$ref2?path=http%3A//s1.amazon.de/exec/varzea/preorder/new/$ref1/ref%3Ddpr%5Fsdp%5Fpo";
    clipboard clear;
    clipboard append $preOrderUrl;
    eval exec [auto_execok start] $preOrderUrl &;
 proc product {{gui 0}} {
    global productUrl;
    while {1} {
       set productUrl [clipboard get];
       if {[string length $productUrl] == 0} {
          set rc   [tk_messageBox \
             -parent  . \
             -icon    error \
             -type    okcancel \
             -title   "empty clipboard" \
             -message "Got no URL, but an empty string!\n\nProbably the clipboard is empty!\n\nRetry?" \
          if {$rc eq "cancel"} {
             if {$gui == 1} {
       } else {
 wm withdraw  .;
 wm title     . "Amazon.de PreOrder";
 wm resizable . 1 0;
 labelframe .lfProduct -text "product URL:";
    label .lfProduct.lUrl -textvariable ::productUrl -justify left -anchor w -width 120;
 pack .lfProduct.lUrl -side top -fill x -expand 1 -padx 3 -pady 3;
 labelframe .lfPreOrder -text "preorder URL:";
    label .lfPreOrder.lUrl -textvariable ::preOrderUrl -justify left -anchor w -width 120;
 pack .lfPreOrder.lUrl -side top -fill x -expand 1 -padx 3 -pady 3;
 frame .fButtons
    button .fButtons.bProduct  -text "product"  -width 7 -command [list product 1];
    button .fButtons.bPreOrder -text "preorder" -width 7 -command preorder;
    button .fButtons.bCancel   -text "cancel"   -width 7 -command exit;
 pack   .fButtons.bProduct .fButtons.bPreOrder -side left -fill none -expand 0 -padx 3 -pady 3;
 pack   .fButtons.bCancel                      -side right -fill none -expand 0 -padx 3 -pady 3;
 pack .lfProduct .lfPreOrder -side top -fill x -expand 1 -padx 3 -pady 3;
 pack .fButtons              -side bottom -fill x -expand 1 -padx 3 -pady 3;
 wm deiconify .;
 grab   .
 if {[string length $::productUrl] == 0} {
    focus -force .fButtons.bProduct;
 } else {
    focus -force .fButtons.bPreOrder;