回答編集履歴
1
サンプルソースの整形
test
CHANGED
@@ -1,35 +1,41 @@
|
|
1
|
-
User-Agentを追加してみました。
|
1
|
+
User-Agentをheaderに追加してみました。
|
2
|
+
|
3
|
+
これで取れると思います。
|
2
4
|
|
3
5
|
|
4
6
|
|
5
|
-
|
7
|
+
```lang-php
|
6
8
|
|
7
|
-
|
9
|
+
<?php
|
8
10
|
|
9
|
-
|
11
|
+
$html = file_get_contents( "http://jp.eurail.com/trains-europe/high-speed-trains/ice" );
|
10
12
|
|
11
|
-
4
|
12
13
|
|
13
|
-
5 $opt = array(
|
14
14
|
|
15
|
-
|
15
|
+
$opt = array(
|
16
16
|
|
17
|
-
|
17
|
+
'http'=>array(
|
18
18
|
|
19
|
-
|
19
|
+
'metho'=>'GET',
|
20
20
|
|
21
|
-
|
21
|
+
'header'=>'User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1'
|
22
22
|
|
23
|
-
|
23
|
+
)
|
24
24
|
|
25
|
-
|
25
|
+
);
|
26
26
|
|
27
|
-
12 $context = stream_context_create( $opt );
|
28
27
|
|
29
|
-
13
|
30
28
|
|
31
|
-
|
29
|
+
$context = stream_context_create( $opt );
|
32
30
|
|
33
|
-
15
|
34
31
|
|
32
|
+
|
33
|
+
$html = file_get_contents( "http://jp.eurail.com/trains-europe/high-speed-trains/ice", false, $context );
|
34
|
+
|
35
|
+
|
36
|
+
|
35
|
-
|
37
|
+
echo $html;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```
|