質問編集履歴
1
vbaコードを更新しました。 divタグ内にあるdata-asinの値の抽出方法を教えてください。宜しくお願い致します。
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
vba
|
13
|
+
vbaスクレイピングで、
|
14
14
|
|
15
15
|
amazon検索一覧URLから、商品のASINだけを抽出したい。ページおくりで、検索の最後まで、一気に抽出したい。
|
16
16
|
|
@@ -30,37 +30,63 @@
|
|
30
30
|
|
31
31
|
|
32
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
|
-
|
33
|
+
Sub testIE()
|
34
|
+
|
35
|
+
Dim I As Integer
|
36
|
+
|
37
|
+
Dim objIE As InternetExplorer 'IEオブジェクトを準備
|
38
|
+
|
39
|
+
Set objIE = CreateObject("Internetexplorer.Application") '新しいIEオブジェクトを作成してセット
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
objIE.Visible = True 'IEを表示
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
I = 2
|
48
|
+
|
49
|
+
Do
|
50
|
+
|
51
|
+
If Range("A" & I) = "" Then Exit Do
|
52
|
+
|
53
|
+
If I > 100 Then Exit Do
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
objIE.navigate Range("A" & I) 'IEでURLを開く
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Call WaitResponse(objIE) '読み込み待ち
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
Dim objDoc As HTMLElementCollection
|
66
|
+
|
67
|
+
Set objDoc = objIE.document
|
68
|
+
|
69
|
+
Dim element As IHTMLElement
|
70
|
+
|
71
|
+
For Each element In objDoc.getElementsByClassName("sg-col-4-of-24 sg-col-4-of-12 sg-col-4-of-36 s-result-item s-asin sg-col-4-of-28 sg-col-4-of-16 sg-col sg-col-4-of-20 sg-col-4-of-32")
|
72
|
+
|
73
|
+
Debug.Print element. 'わからない部分!!!!!
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
Next element
|
82
|
+
|
83
|
+
I = I + 1
|
84
|
+
|
85
|
+
Loop
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
Call WaitResponse(objIE)
|
64
90
|
|
65
91
|
End Sub
|
66
92
|
|
@@ -70,25 +96,49 @@
|
|
70
96
|
|
71
97
|
|
72
98
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
99
|
+
Sub WaitResponse(objIE As Object)
|
100
|
+
|
101
|
+
Do While objIE.Busy = True Or objIE.readyState < READYSTATE_COMPLETE '読み込み待ち
|
102
|
+
|
103
|
+
DoEvents
|
104
|
+
|
105
|
+
Loop
|
106
|
+
|
107
|
+
End Sub
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
肝心のASIN抽出処理部分ですが、HTMLでASINコードが入っているのが
|
120
|
+
|
121
|
+
下記divタグ内のdata-asin=にあるので、getElementByclassNameで取得をしようとしているのですが、
|
122
|
+
|
123
|
+
data-asin=””にあるASINコードはどのようにすると抽出できますか??
|
124
|
+
|
125
|
+
宜しくお願い致します。
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<div ****data-asin="B07HVKS8DM"**** data-index="9" data-uuid="644bd227-abf2-4d00-9fc9-6b8be26f583b" class="sg-col-4-of-24 sg-col-4-of-12 sg-col-4-of-36 s-result-item s-asin sg-col-4-of-28 sg-col-4-of-16 sg-col sg-col-4-of-20 sg-col-4-of-32 __web-inspector-hide-shortcut__" data-cel-widget="search_result_9"><div class="sg-col-inner">
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
<span cel_widget_id="SEARCH_RESULTS-SEARCH_RESULTS" class="celwidget slot=SEARCH_RESULTS template=SEARCH_RESULTS widgetId=search-results index=9" data-cel-widget="SEARCH_RESULTS-SEARCH_RESULTS">
|
92
142
|
|
93
143
|
|
94
144
|
|
@@ -146,11 +196,11 @@
|
|
146
196
|
|
147
197
|
|
148
198
|
|
149
|
-
<span data-component-type="s-product-image" class="rush-component" data-component-id="1
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
<a class="a-link-normal" target="_blank" href="/
|
199
|
+
<span data-component-type="s-product-image" class="rush-component" data-component-id="17">
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
<a class="a-link-normal" target="_blank" href="/%E6%A9%9F%E5%8B%95%E6%88%A6%E5%A3%AB%E3%82%AC%E3%83%B3%E3%83%80%E3%83%A0-MS-09-MS-09R-%E3%83%AA%E3%83%83%E3%82%AF%E3%83%BB%E3%83%89%E3%83%A0-144%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%AB/dp/B07HVKS8DM/ref=sr_1_10?dchild=1&fst=as%3Aoff&qid=1586877663&refinements=p_n_feature_fifteen_browse-bin%3A3307612051%2Cp_76%3A2227292051&rnid=2227291051&rps=1&s=hobby&sr=1-10">
|
154
204
|
|
155
205
|
<div class="a-section aok-relative s-image-square-aspect">
|
156
206
|
|
@@ -160,7 +210,7 @@
|
|
160
210
|
|
161
211
|
|
162
212
|
|
163
|
-
<img src="https://m.media-amazon.com/images/I/
|
213
|
+
<img src="https://m.media-amazon.com/images/I/61tIVRyF7qL._AC_UL320_ML3_.jpg" class="s-image" alt="HGUC 機動戦士ガンダム MS-09 ドム/MS-09R リック・ドム 1/144スケール プラモデル" srcset="https://m.media-amazon.com/images/I/61tIVRyF7qL._AC_UL320_ML3_.jpg 1x, https://m.media-amazon.com/images/I/61tIVRyF7qL._AC_UL480_FMwebp_QL65_.jpg 1.5x, https://m.media-amazon.com/images/I/61tIVRyF7qL._AC_UL640_FMwebp_QL65_.jpg 2x, https://m.media-amazon.com/images/I/61tIVRyF7qL._AC_UL800_FMwebp_QL65_.jpg 2.5x, https://m.media-amazon.com/images/I/61tIVRyF7qL._AC_UL960_FMwebp_QL65_.jpg 3x" data-image-index="9" data-image-load="" data-image-latency="s-product-image" data-image-source-density="1">
|
164
214
|
|
165
215
|
|
166
216
|
|
@@ -171,3 +221,321 @@
|
|
171
221
|
</a>
|
172
222
|
|
173
223
|
</span>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
<div class="a-section a-spacing-none a-spacing-top-small">
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<h2 class="a-size-mini a-spacing-none a-color-base s-line-clamp-4">
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<a class="a-link-normal a-text-normal" target="_blank" href="/%E6%A9%9F%E5%8B%95%E6%88%A6%E5%A3%AB%E3%82%AC%E3%83%B3%E3%83%80%E3%83%A0-MS-09-MS-09R-%E3%83%AA%E3%83%83%E3%82%AF%E3%83%BB%E3%83%89%E3%83%A0-144%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%AB/dp/B07HVKS8DM/ref=sr_1_10?dchild=1&fst=as%3Aoff&qid=1586877663&refinements=p_n_feature_fifteen_browse-bin%3A3307612051%2Cp_76%3A2227292051&rnid=2227291051&rps=1&s=hobby&sr=1-10">
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
<span class="a-size-base-plus a-color-base a-text-normal">HGUC 機動戦士ガンダム MS-09 ドム/MS-09R リック・ドム 1/144スケール プラモデル</span>
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
</a>
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
</h2>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
</div>
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
<div class="a-section a-spacing-none a-spacing-top-micro">
|
296
|
+
|
297
|
+
<div class="a-row a-size-small">
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
<span aria-label="5つ星のうち4.5">
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<span class="a-declarative" data-action="a-popover" data-a-popover="{"max-width":"700","closeButton":false,"position":"triggerBottom","url":"/review/widgets/average-customer-review/popover/ref=acr_search__popover?ie=UTF8&asin=B07HVKS8DM&ref=acr_search__popover&contextId=search"}">
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
<a href="javascript:void(0)" class="a-popover-trigger a-declarative"><i class="a-icon a-icon-star-small a-star-small-4-5 aok-align-bottom"><span class="a-icon-alt">5つ星のうち4.5</span></i><i class="a-icon a-icon-popover"></i></a>
|
326
|
+
|
327
|
+
</span>
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
</span>
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
<span aria-label="36">
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
<a class="a-link-normal" target="_blank" href="/%E6%A9%9F%E5%8B%95%E6%88%A6%E5%A3%AB%E3%82%AC%E3%83%B3%E3%83%80%E3%83%A0-MS-09-MS-09R-%E3%83%AA%E3%83%83%E3%82%AF%E3%83%BB%E3%83%89%E3%83%A0-144%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%AB/dp/B07HVKS8DM/ref=sr_1_10?dchild=1&fst=as%3Aoff&qid=1586877663&refinements=p_n_feature_fifteen_browse-bin%3A3307612051%2Cp_76%3A2227292051&rnid=2227291051&rps=1&s=hobby&sr=1-10#customerReviews">
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
<span class="a-size-base">36</span>
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
</a>
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
</span>
|
380
|
+
|
381
|
+
</div>
|
382
|
+
|
383
|
+
</div>
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
<div class="a-section a-spacing-none a-spacing-top-small">
|
394
|
+
|
395
|
+
<div class="a-row a-size-base a-color-base"><div class="a-row">
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
<a class="a-size-base a-link-normal s-no-hover a-text-normal" target="_blank" href="/%E6%A9%9F%E5%8B%95%E6%88%A6%E5%A3%AB%E3%82%AC%E3%83%B3%E3%83%80%E3%83%A0-MS-09-MS-09R-%E3%83%AA%E3%83%83%E3%82%AF%E3%83%BB%E3%83%89%E3%83%A0-144%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%AB/dp/B07HVKS8DM/ref=sr_1_10?dchild=1&fst=as%3Aoff&qid=1586877663&refinements=p_n_feature_fifteen_browse-bin%3A3307612051%2Cp_76%3A2227292051&rnid=2227291051&rps=1&s=hobby&sr=1-10">
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
<span class="a-price" data-a-size="m" data-a-color="price"><span class="a-offscreen">¥2,480</span><span aria-hidden="true"><span class="a-price-symbol"></span><span class="a-price-whole">¥2,480</span></span></span>
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
</a>
|
424
|
+
|
425
|
+
</div></div>
|
426
|
+
|
427
|
+
</div>
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
<div class="a-section a-spacing-none a-spacing-top-micro">
|
434
|
+
|
435
|
+
<div class="a-row a-size-base a-color-secondary s-align-children-center"><div class="a-row s-align-children-center">
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
<span class="aok-inline-block s-image-logo-view">
|
446
|
+
|
447
|
+
<span class="aok-relative s-icon-text-medium s-prime">
|
448
|
+
|
449
|
+
<i class="a-icon a-icon-prime a-icon-medium" role="img" aria-label="Amazon プライム"></i>
|
450
|
+
|
451
|
+
</span>
|
452
|
+
|
453
|
+
<span>
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
</span>
|
458
|
+
|
459
|
+
</span>
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
<span aria-label="明日中4/16に無料配送">
|
468
|
+
|
469
|
+
<span class="a-text-bold">明日中4/16</span><span>に無料配送</span>
|
470
|
+
|
471
|
+
</span>
|
472
|
+
|
473
|
+
</div></div><div class="a-row a-size-base a-color-secondary">
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
<span aria-label="残り2点 ご注文はお早めに">
|
480
|
+
|
481
|
+
<span class="a-color-price">残り2点 ご注文はお早めに</span>
|
482
|
+
|
483
|
+
</span>
|
484
|
+
|
485
|
+
</div>
|
486
|
+
|
487
|
+
</div>
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
<div class="a-section a-spacing-none a-spacing-top-mini">
|
496
|
+
|
497
|
+
<div class="a-row a-size-base a-color-secondary"><span class="a-size-base a-color-secondary">こちらからもご購入いただけます</span><br><span class="a-color-price">¥1,683</span><span class="a-letter-space"></span>
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
<a class="a-link-normal" href="/gp/offer-listing/B07HVKS8DM/ref=sr_1_10?rnid=2227291051&s=hobby&rps=1&fst=as%3Aoff&qid=1586877663&refinements=p_n_feature_fifteen_browse-bin%3A3307612051%2Cp_76%3A2227292051&sr=1-10&dchild=1">
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
(10点の新品)
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
</a>
|
522
|
+
|
523
|
+
</div>
|
524
|
+
|
525
|
+
</div>
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
</div>
|
532
|
+
|
533
|
+
</div>
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
</span>
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
</div></div>
|