| 14 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
#使用命名空間qbpwcf
|
|
|
4 |
namespace qbpwcf{
|
|
|
5 |
|
|
|
6 |
#匯入外部套件
|
|
|
7 |
include("../allInOneForSOAP.php");
|
|
|
8 |
|
|
|
9 |
#提示執行的函數
|
|
|
10 |
echo "<hr>soap::callService=>local=>catchWebContent::getFullWeb<p>";
|
|
|
11 |
|
|
|
12 |
/*
|
|
|
13 |
|
|
|
14 |
#涵式說明:
|
|
|
15 |
#呼叫WebService
|
|
|
16 |
#回傳的結果
|
|
|
17 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
18 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
19 |
#$result["function"],當前執行的函式名稱.
|
|
|
20 |
#$result["content"],呼叫完WebService所得回傳結果.
|
|
|
21 |
#$result["info"],取得webService的要求資訊.
|
|
|
22 |
#必填的參數:
|
|
|
23 |
#$conf["servicePhpFile"],字串,提供服務內容的php檔案的完整絕對位置,裏面要有1個名爲 $conf["serviceClassName"] 類別
|
|
|
24 |
$conf["servicePhpFile"]="~qbpwcf/samplePage/phplib/qbpwcf/catchWebContent-soap.php";
|
|
|
25 |
#$conf["soapMethod"],字串,要呼叫的方法
|
|
|
26 |
$conf["soapMethod"]="getFullWeb";
|
|
|
27 |
|
|
|
28 |
#涵式說明:
|
|
|
29 |
#抓取的特定網頁的某段內容
|
|
|
30 |
#回傳的結果:
|
|
|
31 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
32 |
#$result["error"],錯誤訊息陣列.
|
|
|
33 |
#$result["function"],函數名稱.
|
|
|
34 |
#$result["webContent"]["lineCount"],爲總共有機行原始碼。
|
|
|
35 |
#$result["webContent"]["full"],爲抓取的全部網頁程式碼
|
|
|
36 |
#$result["webContent"][i],爲第i+1行的程式碼
|
|
|
37 |
#必填的參數:
|
|
|
38 |
#$conf["loadingPotision"],字串,要抓取的網頁網址
|
|
|
39 |
$getFullWeb["loadingPotision"]="http://www.nmp.gov.tw/news/list.php";#要抓取的網頁網址
|
|
|
40 |
#可省略的參數:
|
|
|
41 |
#$conf["startLineNum"],從第幾行開始擷取,預設爲從第1行(第0個元素)。
|
|
|
42 |
#$conf["startLineNum"]="";
|
|
|
43 |
#$conf["endLineNum"],到第幾行結束截取,預設爲從最後一行(最後一個元素)。
|
|
|
44 |
#$conf["endLineNum"]="";
|
|
|
45 |
#$conf["processString"],爲是否要變更特定字串內容,預設爲false,不做變更,若設爲"true"則爲要進行處理字串的功能。
|
|
|
46 |
#$conf["processString"]="";
|
|
|
47 |
#$conf["selectedCharacter"],d爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
48 |
#$conf["selectedCharacter"]=array("");
|
|
|
49 |
#若不設定則預設爲要將這些字串作替換(" ","href","iframe","<",">","<a","/>",";","/","=","#",".","'","$","%","&","|")。
|
|
|
50 |
#$conf["changeTo"],爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
51 |
#$conf["changeTo"]=array("");
|
|
|
52 |
#$conf["changeCharSet"],字元陣列,轉換全文編碼,預設不使用,$conf["changeCharSet"][0]為原始編碼,$conf["changeCharSet"][0]為新的編碼.
|
|
|
53 |
#$conf["changeCharSet"]=array("big5","utf-8");
|
|
|
54 |
#備註:
|
|
|
55 |
#$conf["changeCharSet"]參數沒有效果.
|
|
|
56 |
#參考資料來源:
|
|
|
57 |
#iconv用法 => http://php.net/manual/en/function.iconv.php
|
|
|
58 |
#function getFullWeb($conf){
|
|
|
59 |
|
|
|
60 |
#$conf["argv"],字串陣列,呼叫方法時所要用到的參數內容
|
|
|
61 |
$conf["argv"]=array($getFullWeb);
|
|
|
62 |
#可省略的參數:
|
|
|
63 |
#$conf["ssl"],字串,是否使用ssl,"true"代表要使用;"false"代表不使用,預設爲"false"
|
|
|
64 |
#$conf["ssl"]="false";
|
|
|
65 |
#$conf["serverIp"],字串,服務提供的主機ip位置,預設爲本機"127.0.0.1"
|
|
|
66 |
#$conf["serverIp"]="127.0.0.1";
|
|
|
67 |
#$conf["port"],port通常不用ssl時為80,用ssl時為443.
|
|
|
68 |
#$conf["port"]="443";
|
|
|
69 |
#備註:
|
|
|
70 |
#若$conf["ssl"]設為"true"將會呼叫失敗.
|
|
|
71 |
#目前無法用非80port呼叫主機的服務.
|
|
|
72 |
#參考資料:
|
|
|
73 |
#http://www.cnblogs.com/chance1/archive/2009/04/08/1431949.html
|
|
|
74 |
#http://www.php.net/manual/en/soapclient.soapcall.php
|
|
|
75 |
var_dump(soap::callService($conf));
|
|
|
76 |
unset($conf);
|
|
|
77 |
unset($getFullWeb);#移除可能會導致錯誤的參數
|
|
|
78 |
|
|
|
79 |
*/
|
|
|
80 |
|
|
|
81 |
#提示執行的函數
|
|
|
82 |
echo "<hr>soap::callService=>remote=>catchWebContent::getFullWeb<p>";
|
|
|
83 |
|
|
|
84 |
/*
|
|
|
85 |
|
|
|
86 |
#涵式說明:
|
|
|
87 |
#呼叫WebService
|
|
|
88 |
#回傳的結果
|
|
|
89 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
90 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
91 |
#$result["function"],當前執行的函式名稱.
|
|
|
92 |
#$result["content"],呼叫完WebService所得回傳結果.
|
|
|
93 |
#$result["info"],取得webService的要求資訊.
|
|
|
94 |
#必填的參數:
|
|
|
95 |
#$conf["servicePhpFile"],字串,提供服務內容的php檔案的完整絕對位置,裏面要有1個名爲 $conf["serviceClassName"] 類別
|
|
|
96 |
$conf["servicePhpFile"]="~qbpwcf/samplePage/phplib/qbpwcf/catchWebContent-soap.php";
|
|
|
97 |
#$conf["soapMethod"],字串,要呼叫的方法
|
|
|
98 |
$conf["soapMethod"]="getFullWeb";
|
|
|
99 |
|
|
|
100 |
#涵式說明:
|
|
|
101 |
#抓取的特定網頁的某段內容
|
|
|
102 |
#回傳的結果:
|
|
|
103 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
104 |
#$result["error"],錯誤訊息陣列.
|
|
|
105 |
#$result["function"],函數名稱.
|
|
|
106 |
#$result["webContent"]["lineCount"],爲總共有機行原始碼。
|
|
|
107 |
#$result["webContent"]["full"],爲抓取的全部網頁程式碼
|
|
|
108 |
#$result["webContent"][i],爲第i+1行的程式碼
|
|
|
109 |
#必填的參數:
|
|
|
110 |
#$conf["loadingPotision"],字串,要抓取的網頁網址
|
|
|
111 |
$getFullWeb["loadingPotision"]="http://www.nmp.gov.tw/news/list.php";#要抓取的網頁網址
|
|
|
112 |
#可省略的參數:
|
|
|
113 |
#$conf["startLineNum"],從第幾行開始擷取,預設爲從第1行(第0個元素)。
|
|
|
114 |
#$conf["startLineNum"]="";
|
|
|
115 |
#$conf["endLineNum"],到第幾行結束截取,預設爲從最後一行(最後一個元素)。
|
|
|
116 |
#$conf["endLineNum"]="";
|
|
|
117 |
#$conf["processString"],爲是否要變更特定字串內容,預設爲false,不做變更,若設爲"true"則爲要進行處理字串的功能。
|
|
|
118 |
#$conf["processString"]="";
|
|
|
119 |
#$conf["selectedCharacter"],d爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
120 |
#$conf["selectedCharacter"]=array("");
|
|
|
121 |
#若不設定則預設爲要將這些字串作替換(" ","href","iframe","<",">","<a","/>",";","/","=","#",".","'","$","%","&","|")。
|
|
|
122 |
#$conf["changeTo"],爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
123 |
#$conf["changeTo"]=array("");
|
|
|
124 |
#$conf["changeCharSet"],字元陣列,轉換全文編碼,預設不使用,$conf["changeCharSet"][0]為原始編碼,$conf["changeCharSet"][0]為新的編碼.
|
|
|
125 |
#$conf["changeCharSet"]=array("big5","utf-8");
|
|
|
126 |
#備註:
|
|
|
127 |
#$conf["changeCharSet"]參數沒有效果.
|
|
|
128 |
#參考資料來源:
|
|
|
129 |
#iconv用法 => http://php.net/manual/en/function.iconv.php
|
|
|
130 |
#function getFullWeb($conf){
|
|
|
131 |
|
|
|
132 |
#$conf["argv"],字串陣列,呼叫方法時所要用到的參數內容
|
|
|
133 |
$conf["argv"]=array($getFullWeb);
|
|
|
134 |
#可省略的參數:
|
|
|
135 |
#$conf["ssl"],字串,是否使用ssl,"true"代表要使用;"false"代表不使用,預設爲"false"
|
|
|
136 |
#$conf["ssl"]="false";
|
|
|
137 |
#$conf["serverIp"],字串,服務提供的主機ip位置,預設爲本機"127.0.0.1"
|
|
|
138 |
$conf["serverIp"]="169.254.4.3";
|
|
|
139 |
#$conf["port"],port通常不用ssl時為80,用ssl時為443.
|
|
|
140 |
#$conf["port"]="443";
|
|
|
141 |
#備註:
|
|
|
142 |
#若$conf["ssl"]設為"true"將會呼叫失敗.
|
|
|
143 |
#目前無法用非80port呼叫主機的服務.
|
|
|
144 |
#參考資料:
|
|
|
145 |
#http://www.cnblogs.com/chance1/archive/2009/04/08/1431949.html
|
|
|
146 |
#http://www.php.net/manual/en/soapclient.soapcall.php
|
|
|
147 |
var_dump(soap::callService($conf));
|
|
|
148 |
unset($conf);
|
|
|
149 |
unset($getFullWeb);#移除可能會導致錯誤的參數
|
|
|
150 |
|
|
|
151 |
*/
|
|
|
152 |
|
|
|
153 |
#提示執行的函數
|
|
|
154 |
echo "<hr>soap::callService=>local=>catchWebContent::toHtml<p>";
|
|
|
155 |
|
|
|
156 |
/*
|
|
|
157 |
|
|
|
158 |
#涵式說明:
|
|
|
159 |
#呼叫WebService
|
|
|
160 |
#回傳的結果
|
|
|
161 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
162 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
163 |
#$result["function"],當前執行的函式名稱.
|
|
|
164 |
#$result["content"],呼叫完WebService所得回傳結果.
|
|
|
165 |
#$result["info"],取得webService的要求資訊.
|
|
|
166 |
#必填的參數:
|
|
|
167 |
#$conf["servicePhpFile"],字串,提供服務內容的php檔案的完整絕對位置,裏面要有1個名爲 $conf["serviceClassName"] 類別
|
|
|
168 |
$conf["servicePhpFile"]="~qbpwcf/samplePage/phplib/qbpwcf/catchWebContent-soap.php";
|
|
|
169 |
#$conf["soapMethod"],字串,要呼叫的方法
|
|
|
170 |
$conf["soapMethod"]="toHtml";
|
|
|
171 |
|
|
|
172 |
#函數說明:
|
|
|
173 |
#將特定網址的網頁內容儲存成html檔案
|
|
|
174 |
#回傳結果:
|
|
|
175 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
176 |
#$result["error"],錯誤訊息陣列.
|
|
|
177 |
#$result["function"],當前執行的函式名稱.
|
|
|
178 |
#$result["html"],取得的網頁檔位置.
|
|
|
179 |
#必填參數:
|
|
|
180 |
#$conf["saveLocation"],字串,下載好的網頁要儲存到哪邊
|
|
|
181 |
$toHtml["saveLocation"]="奇摩首頁";
|
|
|
182 |
#$conf["webPageLocation"],字串,要下載的網頁目錄位置與檔案名稱.ex:「function/about.php」
|
|
|
183 |
$toHtml["webPageLocation"]="/";
|
|
|
184 |
#可省略參數:
|
|
|
185 |
#$conf["type"],字串,網頁的協定,預設為"http",可以用的還有"https".
|
|
|
186 |
#$conf["type"]="http";
|
|
|
187 |
#$conf["webHostAddressOrDNS"],字串,網頁所處的IP或DNS,預設為"127.0.0.1".
|
|
|
188 |
$toHtml["webHostAddressOrDNS"]="www.yahoo.com.tw";
|
|
|
189 |
#$conf["port"],字串,要使用的port,預設"80",一般來說http為80,https為443.
|
|
|
190 |
#$conf["port"]="80";
|
|
|
191 |
#function toHtml(&$conf){
|
|
|
192 |
|
|
|
193 |
#$conf["argv"],字串陣列,呼叫方法時所要用到的參數內容
|
|
|
194 |
$conf["argv"]=array($toHtml);
|
|
|
195 |
#可省略的參數:
|
|
|
196 |
#$conf["ssl"],字串,是否使用ssl,"true"代表要使用;"false"代表不使用,預設爲"false"
|
|
|
197 |
#$conf["ssl"]="false";
|
|
|
198 |
#$conf["serverIp"],字串,服務提供的主機ip位置,預設爲本機"127.0.0.1"
|
|
|
199 |
#$conf["serverIp"]="127.0.0.1";
|
|
|
200 |
#$conf["port"],port通常不用ssl時為80,用ssl時為443.
|
|
|
201 |
#$conf["port"]="443";
|
|
|
202 |
#備註:
|
|
|
203 |
#若$conf["ssl"]設為"true"將會呼叫失敗.
|
|
|
204 |
#目前無法用非80port呼叫主機的服務.
|
|
|
205 |
#參考資料:
|
|
|
206 |
#http://www.cnblogs.com/chance1/archive/2009/04/08/1431949.html
|
|
|
207 |
#http://www.php.net/manual/en/soapclient.soapcall.php
|
|
|
208 |
var_dump(soap::callService($conf));
|
|
|
209 |
unset($conf);
|
|
|
210 |
unset($toHtml);#移除可能會導致錯誤的參數
|
|
|
211 |
|
|
|
212 |
*/
|
|
|
213 |
|
|
|
214 |
#提示執行的函數
|
|
|
215 |
echo "<hr>soap::callService=>remote=>catchWebContent::toHtml<p>";
|
|
|
216 |
|
|
|
217 |
/*
|
|
|
218 |
|
|
|
219 |
#涵式說明:
|
|
|
220 |
#呼叫WebService
|
|
|
221 |
#回傳的結果
|
|
|
222 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
223 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
224 |
#$result["function"],當前執行的函式名稱.
|
|
|
225 |
#$result["content"],呼叫完WebService所得回傳結果.
|
|
|
226 |
#$result["info"],取得webService的要求資訊.
|
|
|
227 |
#必填的參數:
|
|
|
228 |
#$conf["servicePhpFile"],字串,提供服務內容的php檔案的完整絕對位置,裏面要有1個名爲 $conf["serviceClassName"] 類別
|
|
|
229 |
$conf["servicePhpFile"]="~qbpwcf/samplePage/phplib/qbpwcf/catchWebContent-soap.php";
|
|
|
230 |
#$conf["soapMethod"],字串,要呼叫的方法
|
|
|
231 |
$conf["soapMethod"]="toHtml";
|
|
|
232 |
|
|
|
233 |
#函數說明:
|
|
|
234 |
#將特定網址的網頁內容儲存成html檔案
|
|
|
235 |
#回傳結果:
|
|
|
236 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
237 |
#$result["error"],錯誤訊息陣列.
|
|
|
238 |
#$result["function"],當前執行的函式名稱.
|
|
|
239 |
#$result["html"],取得的網頁檔位置.
|
|
|
240 |
#必填參數:
|
|
|
241 |
#$conf["saveLocation"],字串,下載好的網頁要儲存到哪邊
|
|
|
242 |
$toHtml["saveLocation"]="奇摩首頁";
|
|
|
243 |
#$conf["webPageLocation"],字串,要下載的網頁目錄位置與檔案名稱.ex:「function/about.php」
|
|
|
244 |
$toHtml["webPageLocation"]="/";
|
|
|
245 |
#可省略參數:
|
|
|
246 |
#$conf["type"],字串,網頁的協定,預設為"http",可以用的還有"https".
|
|
|
247 |
#$conf["type"]="http";
|
|
|
248 |
#$conf["webHostAddressOrDNS"],字串,網頁所處的IP或DNS,預設為"127.0.0.1".
|
|
|
249 |
$toHtml["webHostAddressOrDNS"]="www.yahoo.com.tw";
|
|
|
250 |
#$conf["port"],字串,要使用的port,預設"80",一般來說http為80,https為443.
|
|
|
251 |
#$conf["port"]="80";
|
|
|
252 |
#function toHtml(&$conf){
|
|
|
253 |
|
|
|
254 |
#$conf["argv"],字串陣列,呼叫方法時所要用到的參數內容
|
|
|
255 |
$conf["argv"]=array($toHtml);
|
|
|
256 |
#可省略的參數:
|
|
|
257 |
#$conf["ssl"],字串,是否使用ssl,"true"代表要使用;"false"代表不使用,預設爲"false"
|
|
|
258 |
#$conf["ssl"]="false";
|
|
|
259 |
#$conf["serverIp"],字串,服務提供的主機ip位置,預設爲本機"127.0.0.1"
|
|
|
260 |
$conf["serverIp"]="169.254.4.3";
|
|
|
261 |
#$conf["port"],port通常不用ssl時為80,用ssl時為443.
|
|
|
262 |
#$conf["port"]="443";
|
|
|
263 |
#備註:
|
|
|
264 |
#若$conf["ssl"]設為"true"將會呼叫失敗.
|
|
|
265 |
#目前無法用非80port呼叫主機的服務.
|
|
|
266 |
#參考資料:
|
|
|
267 |
#http://www.cnblogs.com/chance1/archive/2009/04/08/1431949.html
|
|
|
268 |
#http://www.php.net/manual/en/soapclient.soapcall.php
|
|
|
269 |
var_dump(soap::callService($conf));
|
|
|
270 |
unset($conf);
|
|
|
271 |
unset($toHtml);#移除可能會導致錯誤的參數
|
|
|
272 |
|
|
|
273 |
*/
|
|
|
274 |
|
|
|
275 |
#提示執行的函數
|
|
|
276 |
echo "<hr>soap::callService=>local=>catchWebContent::wget<p>";
|
|
|
277 |
|
|
|
278 |
/*
|
|
|
279 |
|
|
|
280 |
#涵式說明:
|
|
|
281 |
#呼叫WebService
|
|
|
282 |
#回傳的結果
|
|
|
283 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
284 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
285 |
#$result["function"],當前執行的函式名稱.
|
|
|
286 |
#$result["content"],呼叫完WebService所得回傳結果.
|
|
|
287 |
#$result["info"],取得webService的要求資訊.
|
|
|
288 |
#必填的參數:
|
|
|
289 |
#$conf["servicePhpFile"],字串,提供服務內容的php檔案的完整絕對位置,裏面要有1個名爲 $conf["serviceClassName"] 類別
|
|
|
290 |
$conf["servicePhpFile"]="~qbpwcf/samplePage/phplib/qbpwcf/catchWebContent-soap.php";
|
|
|
291 |
#$conf["soapMethod"],字串,要呼叫的方法
|
|
|
292 |
$conf["soapMethod"]="wget";
|
|
|
293 |
|
|
|
294 |
#涵式說明:
|
|
|
295 |
#抓取的特定網頁的某段內容
|
|
|
296 |
#回傳的結果:
|
|
|
297 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
298 |
#$result["error"],錯誤訊息陣列.
|
|
|
299 |
#$result["function"],函數名稱.
|
|
|
300 |
#$result["oriWebContent"]["full"],原始檔案的完整內容.
|
|
|
301 |
#$result["oriWebContent"]["byLine"],用陣列儲存的原始檔案逐行內容.
|
|
|
302 |
#$result["oriWebContent"]["lineCount"],原始檔案的總共行數.
|
|
|
303 |
#$result["webContent"]["lineCount"],爲總共有機行原始碼。
|
|
|
304 |
#$result["webContent"]["full"],為檔案的完整內容,爲抓取的全部網頁程式碼
|
|
|
305 |
#$result["webContent"][i],爲第i+1行的程式碼
|
|
|
306 |
#必填的參數:
|
|
|
307 |
$wget["loadingPotision"]="www.yahoo.com.tw";#要抓取的網頁網址
|
|
|
308 |
#可省略的參數:
|
|
|
309 |
#$conf["startLineNum"]="";#從第幾行開始擷取,預設爲從第1行(第0個元素)。
|
|
|
310 |
#$conf["endLineNum"]="";#到第幾行結束截取,預設爲從最後一行(最後一個元素)。
|
|
|
311 |
#$conf["processString"]="";#爲是否要變更特定字串內容,預設爲false,不做變更,若設爲"true"則爲要進行處理字串的功能。
|
|
|
312 |
#$conf["selectedCharacter"]="";#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
313 |
#若不設定則預設爲要將這些字串作替換(" ","href","iframe","<",">","<a","/>",";","/","=","#",".","'","$","%","&","|")。
|
|
|
314 |
#$conf["changeTo"]="";#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
315 |
#function wget($conf){
|
|
|
316 |
|
|
|
317 |
#$conf["argv"],字串陣列,呼叫方法時所要用到的參數內容
|
|
|
318 |
$conf["argv"]=array($wget);
|
|
|
319 |
#可省略的參數:
|
|
|
320 |
#$conf["ssl"],字串,是否使用ssl,"true"代表要使用;"false"代表不使用,預設爲"false"
|
|
|
321 |
#$conf["ssl"]="false";
|
|
|
322 |
#$conf["serverIp"],字串,服務提供的主機ip位置,預設爲本機"127.0.0.1"
|
|
|
323 |
#$conf["serverIp"]="127.0.0.1";
|
|
|
324 |
#$conf["port"],port通常不用ssl時為80,用ssl時為443.
|
|
|
325 |
#$conf["port"]="443";
|
|
|
326 |
#備註:
|
|
|
327 |
#若$conf["ssl"]設為"true"將會呼叫失敗.
|
|
|
328 |
#目前無法用非80port呼叫主機的服務.
|
|
|
329 |
#參考資料:
|
|
|
330 |
#http://www.cnblogs.com/chance1/archive/2009/04/08/1431949.html
|
|
|
331 |
#http://www.php.net/manual/en/soapclient.soapcall.php
|
|
|
332 |
$wgetResult=(soap::callService($conf));
|
|
|
333 |
unset($conf);
|
|
|
334 |
unset($wget);#移除可能會導致錯誤的參數
|
|
|
335 |
|
|
|
336 |
#印出原始的網頁
|
|
|
337 |
echo $wgetResult["content"]["webContent"]["full"];
|
|
|
338 |
|
|
|
339 |
*/
|
|
|
340 |
|
|
|
341 |
#提示執行的函數
|
|
|
342 |
echo "<hr>soap::callService=>remote=>catchWebContent::wget<p>";
|
|
|
343 |
|
|
|
344 |
/*
|
|
|
345 |
|
|
|
346 |
#涵式說明:
|
|
|
347 |
#呼叫WebService
|
|
|
348 |
#回傳的結果
|
|
|
349 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
350 |
#$reuslt["error"],執行不正常結束的錯訊息陣列.
|
|
|
351 |
#$result["function"],當前執行的函式名稱.
|
|
|
352 |
#$result["content"],呼叫完WebService所得回傳結果.
|
|
|
353 |
#$result["info"],取得webService的要求資訊.
|
|
|
354 |
#必填的參數:
|
|
|
355 |
#$conf["servicePhpFile"],字串,提供服務內容的php檔案的完整絕對位置,裏面要有1個名爲 $conf["serviceClassName"] 類別
|
|
|
356 |
$conf["servicePhpFile"]="~qbpwcf/samplePage/phplib/qbpwcf/catchWebContent-soap.php";
|
|
|
357 |
#$conf["soapMethod"],字串,要呼叫的方法
|
|
|
358 |
$conf["soapMethod"]="wget";
|
|
|
359 |
|
|
|
360 |
#涵式說明:
|
|
|
361 |
#抓取的特定網頁的某段內容
|
|
|
362 |
#回傳的結果:
|
|
|
363 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
364 |
#$result["error"],錯誤訊息陣列.
|
|
|
365 |
#$result["function"],函數名稱.
|
|
|
366 |
#$result["oriWebContent"]["full"],原始檔案的完整內容.
|
|
|
367 |
#$result["oriWebContent"]["byLine"],用陣列儲存的原始檔案逐行內容.
|
|
|
368 |
#$result["oriWebContent"]["lineCount"],原始檔案的總共行數.
|
|
|
369 |
#$result["webContent"]["lineCount"],爲總共有機行原始碼。
|
|
|
370 |
#$result["webContent"]["full"],為檔案的完整內容,爲抓取的全部網頁程式碼
|
|
|
371 |
#$result["webContent"][i],爲第i+1行的程式碼
|
|
|
372 |
#必填的參數:
|
|
|
373 |
$wget["loadingPotision"]="www.yahoo.com.tw";#要抓取的網頁網址
|
|
|
374 |
#可省略的參數:
|
|
|
375 |
#$conf["startLineNum"]="";#從第幾行開始擷取,預設爲從第1行(第0個元素)。
|
|
|
376 |
#$conf["endLineNum"]="";#到第幾行結束截取,預設爲從最後一行(最後一個元素)。
|
|
|
377 |
#$conf["processString"]="";#爲是否要變更特定字串內容,預設爲false,不做變更,若設爲"true"則爲要進行處理字串的功能。
|
|
|
378 |
#$conf["selectedCharacter"]="";#爲被選擇要處理的字串/字元,須爲陣列值。
|
|
|
379 |
#若不設定則預設爲要將這些字串作替換(" ","href","iframe","<",">","<a","/>",";","/","=","#",".","'","$","%","&","|")。
|
|
|
380 |
#$conf["changeTo"]="";#爲被選擇的字元要換成什麼字串/字元,須爲陣列值。若不設定,則預設爲更換成""(空字串)。
|
|
|
381 |
#function wget($conf){
|
|
|
382 |
|
|
|
383 |
#$conf["argv"],字串陣列,呼叫方法時所要用到的參數內容
|
|
|
384 |
$conf["argv"]=array($wget);
|
|
|
385 |
#可省略的參數:
|
|
|
386 |
#$conf["ssl"],字串,是否使用ssl,"true"代表要使用;"false"代表不使用,預設爲"false"
|
|
|
387 |
#$conf["ssl"]="false";
|
|
|
388 |
#$conf["serverIp"],字串,服務提供的主機ip位置,預設爲本機"127.0.0.1"
|
|
|
389 |
$conf["serverIp"]="169.254.4.3";
|
|
|
390 |
#$conf["port"],port通常不用ssl時為80,用ssl時為443.
|
|
|
391 |
#$conf["port"]="443";
|
|
|
392 |
#備註:
|
|
|
393 |
#若$conf["ssl"]設為"true"將會呼叫失敗.
|
|
|
394 |
#目前無法用非80port呼叫主機的服務.
|
|
|
395 |
#參考資料:
|
|
|
396 |
#http://www.cnblogs.com/chance1/archive/2009/04/08/1431949.html
|
|
|
397 |
#http://www.php.net/manual/en/soapclient.soapcall.php
|
|
|
398 |
$wgetResult=(soap::callService($conf));
|
|
|
399 |
unset($conf);
|
|
|
400 |
unset($wget);#移除可能會導致錯誤的參數
|
|
|
401 |
|
|
|
402 |
#印出原始的網頁
|
|
|
403 |
echo $wgetResult["content"]["webContent"]["full"];
|
|
|
404 |
|
|
|
405 |
*/
|
|
|
406 |
|
|
|
407 |
}#namespace qbpwcf end
|
|
|
408 |
|
|
|
409 |
?>
|