<?php<br />
require
'libs/config.inc.php'
;<br />
$ch
= curl_init(
"http://opac.hhit.edu.cn:8080/opac/openlink.php?strSearchType=title&strText=天才&displaypg=1000&sort=CATA_DATE&showmode=table"
);<br />curl_setopt(
$ch
, CURLOPT_RETURNTRANSFER, true); // 获取数据返回<br />curl_setopt(
$ch
, CURLOPT_BINARYTRANSFER, true); // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回<br />
$output
= curl_exec(
$ch
);<br />
$output
= preg_match(
'/<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC" class="table_line" id="result_content" >(.*)<\/table>/isu'
,
$output
,
$arr
);<br />
$output
= preg_replace(
"'<tr[^>]*?>'si"
,
""
,
$arr
[0]);<br />
$output
= preg_replace(
"'<table[^>]*?>'si"
,
""
,
$output
);<br />
$output
= preg_replace(
"'<span[^>]*?>'si"
,
""
,
$output
);<br />
$output
= preg_replace(
"'<td[^>]*?>'si"
,
""
,
$output
);<br />
$output
= preg_replace(
"'</td>'si"
,
""
,
$output
);<br />
$output
= preg_replace(
"'</span>'si"
,
""
,
$output
);<br />
$output
=
str_replace
(
"</tr>"
,
"{tr}"
,
$output
);<br />
$output
=
str_replace
(
"\t"
,
""
,
$output
);<br />
$output
=
str_replace
(
" "
,
""
,
$output
);<br />
$output
= preg_replace(
'/ /'
,
""
,
$output
);<br />
$output
= preg_replace(
"'<[/!]*?[^<>]*?>'si"
,
""
,
$output
);<br />
$output
=
explode
(
'{tr}'
,
$output
);<br />
array_pop
(
$output
); //去除数组最后一个空元素<br />
foreach
(
$output
as
$key
=>
$value
) {<br />
$value
= trim(
$value
); <br />
$temp
=
explode
(
"\r\n"
,
$value
);<br />
$output
[
$key
] =
$temp
;<br />}<br />
array_shift
(
$output
);<br />print_r(
$output
);<br />
exit
;<br />
$smarty
->assign(
'arr'
,
$output
); //数组定义模板<br />
$smarty
->display(
'lib.html'
);<br />?>