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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#!/bin/sh
# elvis: ebay -- Search the Ebay auction site
# Author: Moritz Muehlenhoff <jmm@informatik.uni-bremen.de>
. surfraw || exit 1
w3_config_hook () {
def SURFRAW_ebay_country "$SURFRAW_lang"
def SURFRAW_ebay_results 50
}
w3_usage_hook () {
cat <<EOF
Usage: $w3_argv0 [options] [search-string]
Description:
Search the Ebay auction site
Local options:
-country= | -c=
com | Main eBay site (default)
ar | Argentina
at | Austria
au | Australia
nl_BE | Belgium (Flemish)
fr_BE | Belgium (French)
br | Brazil
ca | Canada
ch | Switzerland
cn | China
de | Germany
es | Spain
fr | France
hk | Hong Kong
ie | Ireland
in | India
kr | Korea
my | Malaysia
mx | Mexico
nl | Netherlands
nz | New Zealand
ph | Philippines
pl | Poland
sg | Singapore
se | Sweden
tw | Taiwan
uk UK
Environment: SURFRAW_ebay_country, SURFRAW_lang
-results= | -r
Amount of results per page
Default: 50
Environment: SURFRAW_ebay_results
Examples:
$w3_argv0 -c=de sauerkraut
EOF
w3_global_usage
}
w3_parse_option_hook () {
opt="$1"
optarg="$2"
case "$opt" in
-country=*) setopt SURFRAW_ebay_country $optarg ;;
-c=*) setopt SURFRAW_ebay_country $optarg ;;
-results=*) setopt SURFRAW_ebay_results $optarg ;;
-r=*) setopt SURFRAW_ebay_results $optarg ;;
*) return 1 ;;
esac
return 0
}
w3_config
w3_parse_args "$@"
case "$SURFRAW_ebay_country" in
com|ar|at|be|br|ca|ch|\
de|es|fr|fr_BE|\
nl_BE|ie|in|kr|\
mx|nl|ph|pl) TLD="${SURFRAW_ebay_country}" ;;
uk|nz) TLD="co.${SURFRAW_ebay_country}" ;;
au|hk|sg|my) TLD="com.${SURFRAW_ebay_country}" ;;
cn|zh|zt) TLD="com.cn" ;;
# tw uses hk for searches
tw) TLD="com.hk" ;;
*) TLD="com" ;;
esac
if null "$w3_args"; then
case "$SURFRAW_ebay_country" in
br) url="http://www.mercadolivre.com.${TLD}" ;;
ar|mx) url="http://www.mercadolibre.com.${TLD}" ;;
kr) url="http://www.auction.co.kr" ;;
fr_BE) url="http://www.befr.ebay.be" ;;
nl_BE) url="http://www.benl.ebay.be" ;;
se|sv) url="http://www.tradera.com" ;;
tw) url="http://twexport.ebay.com" ;;
*) url="https://www.ebay.${TLD}" ;;
esac
w3_browse_url "$url"
else
if [ "$SURFRAW_ebay_country" = "nz" ] ; then
# nz uses ebay.com, presumably using referrer to tell it is .nz
# we can't affect referrer without getting browser-specific, so
# just use ebay.com
TLD=com
fi
escaped_args=`w3_url_of_arg $w3_args`
host="http://ebay.${TLD}"
pathstart="search/search.dll?MfcISAPICommand=GetResult&krd=1&ht=1&shortcut=4&SoftProperty=MetaEndSort&cgiurl=http%3A%2F%2Fcgi"
pathend="%2Fws%2F&maxRecordsPerPage=$SURFRAW_ebay_results&st=2&ebaytag1code=77&query=${escaped_args}"
case "$SURFRAW_ebay_country" in
cn|zh|zt) url="http://search.eachnet.com/search/basicsearch.do?satitle=${escaped_args}&sacat=0" ;;
br) url="http://www.mercadolivre.com.${TLD}/jm/search?as_pr_categ_id=&as_word=${escaped_args}" ;;
ar|mx) url="http://www.mercadolibre.com.${TLD}/jm/search?as_pr_categ_id=&as_word=${escaped_args}" ;;
kr) url="http://search.auction.co.kr/search/search.aspx?keyword=${escaped_args}&itemno=&seller=&dom=auction&isSuggestion=No&optSection=%C5%EB%C7%D5%B0%CB%BB%F6&txtKeyword=${escaped_args}&x=0&y=0" ;;
se|sv) url="http://www.tradera.com/search/search_firstpage.aspx?search=${escaped_args}&search_category=-1" ;;
nl_BE) url="http://search.benl.ebay.be/${pathstart}.benl.ebay.be${pathend}" ;;
be|fr_BE) url="http://search.befr.ebay.be/${pathstart}.befr.ebay.be${pathend}" ;;
*) url="${host}/${pathstart}.ebay.${TLD}${pathend}" ;;
esac
w3_browse_url "${url}"
fi
|