質問編集履歴
1
プログラムのソースを載せました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,7 +13,26 @@
|
|
13
13
|
|
14
14
|
で<body>タグの抽出には成功しています。
|
15
15
|
|
16
|
+
```ここに言語を入力
|
17
|
+
<?php
|
16
18
|
|
19
|
+
$url = "https://4travel.jp/travelogue/11405390";
|
20
|
+
|
21
|
+
|
22
|
+
$html = file_get_contents($url,false,$context);
|
23
|
+
$dom = new DOMDocument;
|
24
|
+
@$dom->loadHTML(
|
25
|
+
mb_convert_encoding($html, 'HTML-ENTITIES', 'ASCII,JIS,UTF-8,eucJP-win,SJIS-win'),
|
26
|
+
LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD
|
27
|
+
);
|
28
|
+
|
29
|
+
$xpath = new DOMXPath($dom);
|
30
|
+
|
31
|
+
|
32
|
+
$body_text = $xpath->query('//body/*[not(self::header)]')->item(0)->nodeValue;
|
33
|
+
//$body_text = $xpath->query('//body')->item(0)->nodeValue;
|
34
|
+
echo $body_text;
|
35
|
+
```
|
17
36
|
### 試したこと
|
18
37
|
|
19
38
|
$body = $xpath->query('//body/*[not(self::header)]->item(0)->nodeValue;
|