hous365의 주택 정보 수집
12788 단어 채집하다.
<?php
include('global.php');
$conn = new db();
if(isset($_GET['company'])){
$company = $_GET['company'];
}else{
$company = '';
}
if(isset($_GET['memberid'])){
$memberid = $_GET['memberid'];
}else{
$memberid = '';
}
if(isset($_GET['zj_num'])){
$zj_num = $_GET['zj_num'];
}else{
$zj_num = '';
}
if(isset($_GET['zj_code'])){
$zj_code = $_GET['zj_code'];
}else{
$zj_code = '';
}
$url="http://zsb.house365.com/main.php?infotype=0&price=0&buildarea=0&district=0&keyword=&order_=1&page=".$zj_num."&agentcode=".$zj_code."&pkind=selllist&roomtype=&topic=&order=";
$text = @file_get_contents($url);
preg_match_all('/<td align="center" valign="middle"><a href=\'(.*?)\' target=\'_blank\' title="(.*?)"><img src="http:\/\/sell.house365.com\/images\/sellesflist_12.gif" width="77" height="18" border="0" \/><\/a><\/td>/i',$text,$row);
$num_all = 0;
$len = count($row[1]);
//$len = 1;
for($i=0;$i<$len;$i++)
{
$mrent = array();
$url1 = $row[1][$i];
$text1 = @file_get_contents($url1);
$mrent['coltype'] = 'second';
$mrent['menuid'] = '10';
$mrent['memberid'] = $memberid;
$mrent['memberprop'] = '2';
$mrent['shangquan'] = '0';
$mrent['infotype'] = 'sale';
$mrent['jz'] = '1';
$mrent['menuid'] ='10';
$mrent['author'] = $company;//iconv("UTF-8", "GBK", $company);
//
preg_match_all('/<td colspan="2" class="fy_name"><h1 style="text-align:center;font-size:20px;font-family: ;font-weight:normal">(.*?)<\/h1><\/td>/i',$text1,$name_arr);
$louopan = trim($name_arr[1][0]);
$mrent['loupan'] =iconv( "GBK","UTF-8", $louopan);
//
preg_match_all('/<td width="215" class="dash_line"> :<span>(.*?)<\/span> /i',$text1,$rentall_arr);
$rentall = trim($rentall_arr[1][0]);
$mrent['rentall'] = $rentall;
//
preg_match_all('/<td class="dash_line"> :<span>(.*?)<\/span> <\/td>/i',$text1,$area_arr);
$area = trim($area_arr[1][0]);
$mrent['area'] = $area;
//
preg_match_all('/<td class="dash_line"> :(\d*) \/ <\/td>/i',$text1,$rentavg_arr);
$rentaverage = trim($rentavg_arr[1][0]);
$mrent['rentaverage'] =$rentaverage;
//
preg_match_all('/<td class="dash_line"> :(\d) (\d) (\d) (\d) <\/td>/i',$text1,$type_arr);
$shi = $type_arr[1][0];
$ting = $type_arr[2][0];
$wei = $type_arr[3][0];
$tai = $type_arr[4][0];
$mrent['shi'] = $shi;
$mrent['ting'] = $ting;
$mrent['wei'] = $wei;
$mrent['tai'] = $tai;
//
preg_match_all('/<td class="dash_line"> :(\d*) , (\d*) <\/td>/i',$text1,$floor_arr);
$nowfloor = trim($floor_arr[1][0]);
$allfloors = trim($floor_arr[2][0]);
$mrent['nowfloor'] = $nowfloor;
$mrent['allfloors'] = $allfloors;
//
preg_match_all('/<td class="dash_line"> :(\d*) <\/td>/i',$text1,$buildtime_arr);
$buildtime = trim($buildtime_arr[1][0]);
$mrent['buildtime'] = $buildtime;
//
preg_match_all('/<td class="dash_line"> :(.*?)<\/td>/i',$text1,$upholster_arr);
$upholster = trim($upholster_arr[1][0]);
switch($upholster){
case " ":
$fitment = 1;
break;
case " ":
$fitment = 2;
break;
case " ":
$fitment = 3;
break;
case " ":
$fitment = 4;
break;
default:
$fitment = 1;
break;
}
$mrent['fitment'] = $fitment;
//
preg_match_all('/<td class="dash_line"> :(.*?)<\/td>/i',$text1,$face_arr);
$face_to = trim($face_arr[1][0]);
$mrent['chaoxiang'] = iconv( "GBK","UTF-8", $face_to);
//
preg_match_all('/<td class="dash_line"> :<a (.*?)>(.*?)<\/a><\/td>/i',$text1,$housetype_arr);
$housetype = trim($housetype_arr[2][0]);
$mrent['housetype'] = iconv( "GBK","UTF-8", $housetype);
$cat_arr =array(
"2" => " " ,
"31" =>" " ,
"32" =>" " ,
"33" =>" " ,
);
if(in_array($housetype,$cat_arr)){
$catid = array_search($housetype,$cat_arr);
}else{
$catid = 0;
}
$mrent['catid'] = $catid;
//
preg_match_all('/<td class="dash_line"> :(.*?)<\/td>/i',$text1,$uptime_arr);
$uptime = strtotime(trim($uptime_arr[1][0]));
$mrent['uptime'] = $uptime;
//
preg_match_all('/<td width="220" class="dash_line"> :<a (.*?)>(.*?)<\/a>\s<\/td>/i',$text1,$cat_arr);
$cat = trim($cat_arr[2][0]);
$district =array(
"46" => " ",
"45" => " ",
"48" => " ",
"49" => " ",
"47" => " ",
"44" => " ",
"51" => " ",
"50" => " ",
"52" => " ",
"53" => " ",
"54" => " ",
"55" => " ",
"56" => " ",
"60" => " ",
);
$zoneid = array_search($cat,$district);
$mrent['zoneid'] = $zoneid;
//
preg_match_all('/<td width="150" class="dash_line"> :<a (.*?)>(.*?)<\/a> <\/td>/i',$text1,$board_arr);
$board = trim($board_arr[2][0]);
$board = iconv( "GBK","UTF-8", $board);
$sql = "SELECT id FROM `quyu` where sort =$zoneid and `name` like '%".$board."%'";
$quyu = $conn-> Query2SingleRowArray($sql);
$mrent['quyu'] =$quyu['id'];
//
preg_match_all('/<td class="dash_line"> :<a (.*?)>(.*?)<\/a><\/td>\s*<td class="dash_line">(.*?)<\/td>/i',$text1,$xiaoqu_arr);
$xq_name = trim($xiaoqu_arr[2][0]);
$xq_address = trim($xiaoqu_arr[3][0]);
$mrent['address'] = iconv( "GBK","UTF-8", $xq_address);
//
preg_match_all('/<td width="245" align="center"><strong><span>(.*?)<\/span><\/strong><\/td>\s*<td width="185"> :<span>(.*?)<\/span><\/td>/i',$text1,$lxr_arr);
$lxr_tel = trim($lxr_arr[1][0]);
$lxr_name = trim($lxr_arr[2][0]);
$mrent['lxr'] = iconv( "GBK","UTF-8", $lxr_name);
$th_tel = array('<span style="font-size:14px">','</span>');
$lxr_tel = str_replace($th_tel,"",$lxr_tel);
$tel_arr = explode("-",$lxr_tel);
for($tj=0;$tj<count($tel_arr);$tj++)
{
$tel_len = strlen($tel_arr[$tj]);
if($tel_len==11)
{
$mrent['lxdh'] = $tel_arr[$tj];
//$mrent['lxrshouji'] = $tel_arr[$tj];
}else{
$mrent['lxdh'] = $tel_arr[$tj];
}
}
//
preg_match_all('/<div class="infor_fp_con">\s*(.*?)\s*<\/div>/i',$text1,$info_arr);
$info = explode("<br>",$info_arr[1][0]);
$fbdate = trim($info[0]);
for($j=1;$j<count($info);$j++)
{
$if_type = substr($info[$j],0,10);
switch($if_type)
{
case " :":
$bus = substr(trim($info[$j]),10);
break;
case " :":
$base = substr(trim($info[$j]),10);
break;
case " :":
$attach = substr(trim($info[$j]),10);
break;
}
}
$mrent['fbdate'] = iconv( "GBK","UTF-8", $fbdate);
// $mrent['froute'] = iconv( "GBK","UTF-8", $bus);
$jichu = $base.','.$attach;
$jc = explode(",",$jichu);
foreach($jc as $jc_value)
{
switch($jc_value)
{
case " " :
$facnet = 1;
case " ":
$facgas = 1;
case " ":
$factvnet = 1;
case " " :
$facphone = 1;
case " " :
$facfridge = 1;
case " " :
$factv = 1;
case " " :
$facwasher = 1;
case " " :
$facwheater = 1;
case " " :
$facaircon = 1;
case " " :
$facfurniture = 1;
}
}
$mrent['facfurniture'] = $facfurniture;
$mrent['factvnet'] = $factvnet;
$mrent['factv'] = $factv;
$mrent['facnet'] = $facnet;
$mrent['facphone'] = $facphone;
$mrent['facwheater'] = $facwheater;
$mrent['facaircon'] = $facaircon;
$mrent['facwasher'] = $facwasher;
$mrent['facfridge'] = $facfridge;
$mrent['facgas'] = $facgas;
if($mrent['loupan']!='')
{
$sql = "SELECT id FROM `hou_mrent` where memberid =$memberid loupan ='".$mrent['loupan']."'";
$chk = $conn-> Query2SingleRowArray($sql);
if($chk['id']==''){
$conn ->insert('hou_mrent',$mrent,$debug = true);
$rows = $conn->GetQueryAffectedRows();
if($rows>0)
{
$num_all++;
}
}
}
}
$note = " , ".$num_all." ";
$note = iconv("GBK", "UTF-8", $note);
?>
<script type="text/javascript">
parent.document.all('note').innerHTML="<?=$note?>";
parent.document.all('btn_sc').disabled="";
parent.document.all('btn_zq').disabled="";
</script>