回答編集履歴
2
追記
test
CHANGED
@@ -24,8 +24,60 @@
|
|
24
24
|
|
25
25
|
var asin = searchBy(rootHtml, '<div data-caution="', '">', 'class="search_item_list_section"', 100000, 10)
|
26
26
|
|
27
|
-
Logger.log(asin)
|
27
|
+
Logger.log("asin:%s",asin)
|
28
28
|
|
29
29
|
}
|
30
30
|
|
31
31
|
```
|
32
|
+
|
33
|
+
## 追記
|
34
|
+
|
35
|
+
上記`test()`を実行していただいて、ログを確認してみてください。
|
36
|
+
|
37
|
+
おそらく`asin:null`が出力されているかと思います。
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
その場合、`searchStartKey not found`もログに出力されているか確認してください。
|
42
|
+
|
43
|
+
(おそらく出力されていないはず)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
出力されていなければ、
|
48
|
+
|
49
|
+
`searchBy`関数に下記を足して、ログをみてみてください。
|
50
|
+
|
51
|
+
```js
|
52
|
+
|
53
|
+
function searchBy (target, startKey, endKey, searchStartKey, searchLength, searchRepeat) {
|
54
|
+
|
55
|
+
/*** ここまで省略 ***/
|
56
|
+
|
57
|
+
var startIndex = startKey !== null ? target.indexOf(startKey) + startKey.length : 0
|
58
|
+
|
59
|
+
var endIndex = endKey !== null ? target.indexOf(endKey, startIndex) : target.length
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
// ログの出力を追加
|
64
|
+
|
65
|
+
Logger.log("startKey:%s, startIndex:%s, startKey.length:%s, endIndex:%s",startKey, startIndex, startKey.length, endIndex)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
if ((startKey === null || startIndex !== (startKey.length - 1)) && endIndex !== -1) {
|
70
|
+
|
71
|
+
return target.substring(startIndex, endIndex)
|
72
|
+
|
73
|
+
} else {
|
74
|
+
|
75
|
+
return null
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
おそらく、このログで何が原因で止まっているかがわかるかと思うのですが…。
|
1
追記
test
CHANGED
@@ -13,3 +13,19 @@
|
|
13
13
|
```
|
14
14
|
|
15
15
|
`searchBy`という名前から何かデータから検索しているのだろうと考えられますが、`si=10`のときに正しく動いているかを確認するほうがよいですね。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
```js
|
20
|
+
|
21
|
+
function test() {
|
22
|
+
|
23
|
+
var rootHtml = getHtml('サイトのURL' + 1)
|
24
|
+
|
25
|
+
var asin = searchBy(rootHtml, '<div data-caution="', '">', 'class="search_item_list_section"', 100000, 10)
|
26
|
+
|
27
|
+
Logger.log(asin)
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
```
|