回答編集履歴
2
追記
answer
CHANGED
@@ -11,6 +11,32 @@
|
|
11
11
|
function test() {
|
12
12
|
var rootHtml = getHtml('サイトのURL' + 1)
|
13
13
|
var asin = searchBy(rootHtml, '<div data-caution="', '">', 'class="search_item_list_section"', 100000, 10)
|
14
|
-
Logger.log(asin)
|
14
|
+
Logger.log("asin:%s",asin)
|
15
15
|
}
|
16
|
-
```
|
16
|
+
```
|
17
|
+
## 追記
|
18
|
+
上記`test()`を実行していただいて、ログを確認してみてください。
|
19
|
+
おそらく`asin:null`が出力されているかと思います。
|
20
|
+
|
21
|
+
その場合、`searchStartKey not found`もログに出力されているか確認してください。
|
22
|
+
(おそらく出力されていないはず)
|
23
|
+
|
24
|
+
出力されていなければ、
|
25
|
+
`searchBy`関数に下記を足して、ログをみてみてください。
|
26
|
+
```js
|
27
|
+
function searchBy (target, startKey, endKey, searchStartKey, searchLength, searchRepeat) {
|
28
|
+
/*** ここまで省略 ***/
|
29
|
+
var startIndex = startKey !== null ? target.indexOf(startKey) + startKey.length : 0
|
30
|
+
var endIndex = endKey !== null ? target.indexOf(endKey, startIndex) : target.length
|
31
|
+
|
32
|
+
// ログの出力を追加
|
33
|
+
Logger.log("startKey:%s, startIndex:%s, startKey.length:%s, endIndex:%s",startKey, startIndex, startKey.length, endIndex)
|
34
|
+
|
35
|
+
if ((startKey === null || startIndex !== (startKey.length - 1)) && endIndex !== -1) {
|
36
|
+
return target.substring(startIndex, endIndex)
|
37
|
+
} else {
|
38
|
+
return null
|
39
|
+
}
|
40
|
+
}
|
41
|
+
```
|
42
|
+
おそらく、このログで何が原因で止まっているかがわかるかと思うのですが…。
|
1
追記
answer
CHANGED
@@ -5,4 +5,12 @@
|
|
5
5
|
break
|
6
6
|
}
|
7
7
|
```
|
8
|
-
`searchBy`という名前から何かデータから検索しているのだろうと考えられますが、`si=10`のときに正しく動いているかを確認するほうがよいですね。
|
8
|
+
`searchBy`という名前から何かデータから検索しているのだろうと考えられますが、`si=10`のときに正しく動いているかを確認するほうがよいですね。
|
9
|
+
|
10
|
+
```js
|
11
|
+
function test() {
|
12
|
+
var rootHtml = getHtml('サイトのURL' + 1)
|
13
|
+
var asin = searchBy(rootHtml, '<div data-caution="', '">', 'class="search_item_list_section"', 100000, 10)
|
14
|
+
Logger.log(asin)
|
15
|
+
}
|
16
|
+
```
|