質問編集履歴
4
質問されたことに対して修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
```
|
16
|
+
|
17
|
+
<?php
|
16
18
|
|
17
19
|
header("Content-Type: text/html; charset=UTF-8");
|
18
20
|
|
@@ -56,4 +58,56 @@
|
|
56
58
|
|
57
59
|
$data2 = get_object_vars($xml2);
|
58
60
|
|
61
|
+
foreach ((array)$data2['room'] as $url2) {
|
62
|
+
|
63
|
+
$building_cd = $url2->real_building_name;//物件ID
|
64
|
+
|
65
|
+
//テキストファイルに保存
|
66
|
+
|
67
|
+
$fp = fopen('list.txt', 'a');
|
68
|
+
|
69
|
+
if ($fp){
|
70
|
+
|
71
|
+
if (flock($fp, LOCK_EX)){
|
72
|
+
|
73
|
+
if (fwrite($fp, $building_cd."\n") === FALSE){
|
74
|
+
|
75
|
+
print('ファイル書き込みに失敗しました<br>');
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
flock($fp, LOCK_UN);
|
80
|
+
|
81
|
+
}else{
|
82
|
+
|
83
|
+
print('ファイルロックに失敗しました<br>');
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
$flag = fclose($fp);
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
if ($flag){
|
98
|
+
|
99
|
+
print('URLリストを「list.txt」に保存しました');
|
100
|
+
|
101
|
+
}else{
|
102
|
+
|
103
|
+
print('クローズに失敗しました');
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
echo "全て取り込み完了しました";
|
108
|
+
|
109
|
+
?>
|
110
|
+
|
111
|
+
|
112
|
+
|
59
113
|
```
|
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,6 +13,12 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
```
|
16
|
+
|
17
|
+
header("Content-Type: text/html; charset=UTF-8");
|
18
|
+
|
19
|
+
unlink("list.txt");
|
20
|
+
|
21
|
+
require_once( dirname(__FILE__) . '/wp-load.php' );
|
16
22
|
|
17
23
|
$xml = simplexml_load_file('http://hoge.jp/city/?key=000&pref_cd=14');
|
18
24
|
|
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
if($i = 0){
|
32
32
|
|
33
|
-
$detail = "http://hoge.jp/room/?key=
|
33
|
+
$detail = "http://hoge.jp/room/?key=000&city_cd=" . $url->code;
|
34
34
|
|
35
35
|
} else {
|
36
36
|
|
1
質問が来たので
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,12 +14,40 @@
|
|
14
14
|
|
15
15
|
```
|
16
16
|
|
17
|
-
$
|
17
|
+
$xml = simplexml_load_file('http://hoge.jp/city/?key=000&pref_cd=14');
|
18
18
|
|
19
|
-
|
19
|
+
$data = get_object_vars($xml);
|
20
20
|
|
21
|
-
$results_count = $i*50;
|
22
21
|
|
22
|
+
|
23
|
+
foreach ($data['city'] as $url) {
|
24
|
+
|
25
|
+
$results_available = ceil($data2['results_available']/50);
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
for($i = 0; $i < $results_available; $i++){
|
30
|
+
|
31
|
+
if($i = 0){
|
32
|
+
|
33
|
+
$detail = "http://hoge.jp/room/?key=QYGFU8OP&city_cd=" . $url->code;
|
34
|
+
|
35
|
+
} else {
|
36
|
+
|
37
|
+
$results_i = ($i*50)+1;
|
38
|
+
|
39
|
+
$results_count = "&start=" . $results_i . "&count=50";
|
40
|
+
|
41
|
+
$detail = "http://hoge.jp/room/?key=000&city_cd=" . $url->code . $results_count;
|
42
|
+
|
23
|
-
}
|
43
|
+
}
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
$xml2 = simplexml_load_file($detail);
|
50
|
+
|
51
|
+
$data2 = get_object_vars($xml2);
|
24
52
|
|
25
53
|
```
|