File: amazon

package info (click to toggle)
surfraw 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,624 kB
  • sloc: sh: 7,977; perl: 824; makefile: 277
file content (244 lines) | stat: -rwxr-xr-x 9,241 bytes parent folder | download | duplicates (3)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/sh
# $Id$
# elvis: amazon		-- Search the amazon.com bookstore
. surfraw || exit 1

w3_config_hook () {
def   SURFRAW_amazon_country	"$SURFRAW_lang"
def   SURFRAW_amazon_search	all
}

w3_usage_hook () {
    cat <<EOF
Usage: $w3_argv0 [options] [search-string]
Description:
  Search amazon
Local options:
  -country=COUNTRY              Two letter domain-style country code
           com              |   Main amazon.com site (default)
           ca               |   Canada
           cn               |   China
           de               |   Germany
           fr               |   France
           jp               |   Japan
           uk                   UK
                                Environment: SURFRAW_amazon_country, SURFRAW_lang
                                Default: $SURFRAW_amazon_country
  -search=                      Specialised search on topic
            all                 All Departments.
      amazon.com:
            apparel             Apparel & Accessories
            automotive          Automotive
            baby-products       Baby
            beauty              Beauty
            books               Books
            wireless-aps        Cell Phones & Service
            electronics         Electronics
            misc                Everything Else
            gourmet             Gourmet Food
            grocery             Grocery
            hpc                 Health & Personal Care
            garden              Home & Garden
            tools               Home Improvement
            industrial          Industrial & Scientific
            jewelry             Jewelry
            digital-text        Kindle Store
            magazines           Magazines
            dvd                 Movies & TV
            digital-music       MP3 Downloads
            popular             Music
            mi                  Musical Instruments
            office-products     Office Products & Supplies
            shoes               Shoes
            software            Software
            sporting            Sports & Outdoors
            toys-and-games      Toys & Games
            vhs                 VHS
            videogames          Video Games
            amazontv            Video On Demand
            watches             Watches
    uk:
            books               Books
            electronics         Electronics
            popular             Music
            classical           Classical Music
            digital-music       MP3 Downloads
            dvd                 DVD
            vhs                 VHS
            software            Software
            videogames          Video Games
            software-videogames Software & Games
            diy                 DIY & Tools
            outdoor             Garden & Outdoors
            kitchen             Kitchen & Home
            drugstore           Health & Beauty
            beauty              Beauty
            toys                Toys & Games
            sports              Sports & Leisure
            jewelry-watches     Jewellery & Watches
            clothing            Clothing
            shoes               Shoes & Accessories
            baby                Baby
    fr:
            books               Livres en français
            english-books       Livres en anglais
            electronics         High-tech
            popular             Musique
            classical           Musique classique
            dvd                 DVD & Vidéo
            blu-ray             Blu-ray
            software            Logiciels
            videogames          Jeux vidéo
            toys                Jeux et Jouets
            kitchen             Cuisine & Maison
            jewelry-watches     Montres & Bijoux
    de:
            books               Bücher
            english-books       Englische Bücher
            magazines           Zeitschriften
            popular             Musik
            classical           Klassische Musik
            dvd                 DVD
            blu-ray             Blu-ray
            electronics         Elektronik & Foto
            computer            Computer
            photo               Kamera & Foto
            kitchen             Küche & Haushalt
            diy                 Baumarkt
            automotive          Auto & Motorrad
            outdoor             Garten & Freizeit
            drugstore           Drogerie & Bad
            beauty              Parfümerie & Kosmetik
            software            Software
            videogames          Games
            toys                Spielzeug
            sports              Sport & Freizeit
            jewelry-watches     Uhren & Schmuck
            baby                Babyausstattung
            clothing            Bekleidung
            shoes               Schuhe & Handtaschen
    ca:
            books               Books
            popular             Music
            classical           Classical Music
            dvd                 DVD
            vhs                 VHS
            electronics         Electronics
            software            Software
            videogames          Video Games
    jp:
            books               a書
            english-books       m酪
            electronics         痩d&塔Jメラ
            kitchen             zメ[ム&Lャb\`ャ
            popular             塔~ュ[<WbャN
            classical           Nャ宴VbャN音y
            dvd                 DVD
            software            PC潟\tャg
            videogames          Qメ[ム
            toys                おもちゃ&zャr[
            sporting            <X|メ[c&ャAEャghャA
            hpc                 wャ泣X&rャ[eャB[
            beauty              <RXャ
            food-beverage       $Hi&譜料
            watch               時v
            baby                激xrメ[&}ャ^jャeB
            apparel             ャApャ激&泣t@ャbVャ梼G貨
    cn:
            1                   图书
            2                   音乐
            3                   影视
            5                   手机
            6                   家电
            7                   化妆
            8                   厨具
            9                   家居
            10                  运动健康
            11                  玩具
            12                  钟表首饰
            14                  个人护理
            15                  软件
            16                  游戏/娱乐
            17                  礼品箱包
            20                  摄影摄像
            21                  Mp3/Mp4
            22                  视听设备
            23                  电脑配件
            25                  教育音像
                                Default: $SURFRAW_amazon_search
                                Environment: SURFRAW_amazon_search

Examples:
  $w3_argv0 -search=books -country=uk -q The Lotus and The Robot
EOF
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
	-search=*)	setopt	SURFRAW_amazon_search		$optarg ;;
	-country=*)	setopt	SURFRAW_amazon_country		$optarg	;;
	*) return 1 ;;
    esac
    return 0
}

w3_config
w3_parse_args "$@"
# w3_args now contains a list of arguments

case "$SURFRAW_amazon_country" in
    uk) host=www.amazon.co.uk	      ;;
    de) host=www.amazon.de	      ;;
    fr) host=www.amazon.fr	      ;;
    jp) host=www.amazon.co.jp	      ;;
    ca) host=www.amazon.ca	      ;;
    cn|zh|zt) host=www.amazon.cn      ;;
    *)  host=www.amazon.com	      ;;
esac

if null "$w3_args"; then
    w3_browse_url "https://${host}/"
else
    escaped_args=`w3_url_of_arg $w3_args`
    if [ "$SURFRAW_amazon_search" = books ] ; then
	SURFRAW_amazon_search=stripbooks
    elif [ "$SURFRAW_amazon_search" = all ] ; then
	SURFRAW_amazon_search=aps
    fi
    case "$host" in
    www.amazon.cn)
    	path="mn/searchApp"
	if [ "$SURFRAW_amazon_search" = "aps" ] ;then
	    SURFRAW_amazon_search=""
	fi
	args="ix=sunray&pageletid=headsearch&searchType=${SURFRAW_amazon_search}&keywords=${escaped_args}&Go.x=0&Go.y=0&bestSaleNum=0"
	 break;;
    www.amazon.co.jp)
    	path="s/ref=nb_ss_gw"
    	args="__mk_ja_JP=%83J%83%5E%83J%83i&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
	break;;
    www.amazon.co.uk)
    	path="s/ref=nb_ss_w_h_"
    	args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
	break;;
    www.amazon.fr)
        path="s/ref=nb_ss_w"
	args="__mk_fr_FR=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
	break;;
    www.amazon.de)
        path="s/ref=nb_ss_w"
	args="__mk_de_DE=%C5M%C5Z%D5%D1&url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
	break;;
    www.amazon.ca)
	path="s/ref=nb_ss_gw"
	args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
	break;;
    *)
        path="s/ref=nb_ss_gw"
	args="url=search-alias%3D${SURFRAW_amazon_search}&field-keywords=${escaped_args}"
    esac
    w3_browse_url "https://${host}/${path}?${args}"
fi