teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

参考追加

2022/09/21 03:53

投稿

minato2000
minato2000

スコア10

title CHANGED
File without changes
body CHANGED
@@ -76,3 +76,6 @@
76
76
  "xpath": "^0.0.32"
77
77
  }
78
78
  ```
79
+
80
+ ### 参考
81
+ https://qiita.com/ledsun/items/0965a60f9bdff04f2fa0#xpath-parse5

2

試したこと追加

2022/09/21 03:46

投稿

minato2000
minato2000

スコア10

title CHANGED
File without changes
body CHANGED
@@ -48,9 +48,17 @@
48
48
  + const items = select('//x:a', doc)
49
49
  ```
50
50
 
51
+ - 別のWebサイトでXPathの動作確認をしたが、「0個の要素が見つかりました」が表示された。
52
+ ```diff
53
+ - const url = 'https://gundamevolution.jp/news/'
54
+ + const url = 'http://example.com'
51
55
 
56
+ - const items = select('//x:a[contains(@class, "news-list__item")]', doc)
57
+ + const items = select('//x:a', doc)
58
+ ```
52
59
 
53
60
 
61
+
54
62
  ### 補足情報(FW/ツールのバージョンなど)
55
63
  - Windows 11 21H2
56
64
 

1

試したこと追加

2022/09/21 03:30

投稿

minato2000
minato2000

スコア10

title CHANGED
File without changes
body CHANGED
@@ -36,6 +36,12 @@
36
36
  ```
37
37
 
38
38
  ### 試したこと
39
+ - fetchで取得したHTMLに問題がないかを確認したが、ニュースのタイトルなどがout.htmlで確認出来たので問題ないと判断した。
40
+ ```diff
41
+ + const fs = require('fs');
42
+ + fs.writeFileSync('out.html', text)
43
+ ```
44
+
39
45
  - 簡単なXPathに置き換えてXPathの動作確認をしたが、「0個の要素が見つかりました」が表示された。
40
46
  ```diff
41
47
  - const items = select('//x:a[contains(@class, "news-list__item")]', doc)