油漆工程承包,居家油漆粉刷、外牆油漆
油漆老師傅專業施工,來電免費估價!
搬家公司內外玄關門、優質採光罩、藝術欄杆
各種材質、造型門窗設計工程,歡迎洽詢

首頁  •  tw 論壇 • 程式設計討論     • 

preg_match_all() 取出網頁資料

房東:台灣人
發表時間:2007-05-11
[檢舉]



// 下載網頁
$handle = fopen(\"http://www.30p.com.tw/House/House_Info.aspx?house_no=1041994\", \"r\");
$contents = fread($handle, 10000 );
fclose($handle);

// 取出資料
$result = array();
preg_match_all(\"/([^<]+)<\\/span>/\", $contents, $result, PREG_SET_ORDER);

foreach ( $result as $key => $value ) {

$span_id = $result[ $key ][1];
$span_value = $result[ $key ][2];

switch ( $span_id ) {
case \"lblContactName\":
$lblContactName = $span_value;
break;
case \"lblContactMobile\":
$lblContactMobile = $span_value;
break;
case \"lblContactPhone1\":
$lblContactPhone1 = $span_value;
break;
case \"lblContactPhone2\":
$lblContactPhone2 = $span_value;
break;
case \"lblContactEmail\":
$lblContactEmail = $span_value;
break;
}
}

// 顯示資料
print \"姓名: $lblContactName 手機: $lblContactMobile 聯絡電話(日): $lblContactPhone1 聯絡電話(夜): $lblContactPhone2 email $lblContactEmail\";

?>




  • 贊助網站       

    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!
    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務

  • 1 樓住戶:仙人
    發表時間:2007-05-13
    [檢舉]
    \s\n\s+

    ob_start ();
    readfile ("http://www.168house.com/showpage.php?number=94567");
    $data = ob_get_contents ();
    ob_end_clean ();

    preg_match_all ('/\s+
    (.*)<\/font><\/td>\n\s+(.*)<\/font><\/td>\n\s+(.*)<\/font><\/td>\n\s+(.*)<\/font><\/td>\n\s+<\/tr>/i', $data, $matchse);
    print_r (trim (preg_replace ("/ /U", "", strip_tags ($matchse[0][0]))));

    2 樓住戶:阿保
    發表時間:2007-05-14
    [檢舉]

    //----- 定義要擷取的網頁地址
    $url = "http://web-address";

    //----- 讀取網頁源始碼
    $fp = file_get_contents($url);

    //----- 擷取 title 資訊
    preg_match("/(.*)<\/title>/s", $fp, $match);<br /> $title = $match[1];<br /> <br /> //----- 擷取 Description 及 Keywords<br /> $metatag = get_meta_tags($url);<br /> $description = $metatag["description"];<br /> $keywords = $metatag["keywords"];<br /> <br /> //----- 印出結果<br /> echo "URL: $url\n";<br /> echo "Title: $title\n";<br /> echo "Description: $description\n";<br /> echo "Keywords: $keywords\n";<br /> ?> <br></div><tr><td align="right"> </td></tr> </td></tr></table></center><br> <center><table width="80% nowrap> <tr><td><table width="100%" CELLPADDING="0" CELLSPACING="2" bgcolor="#CEE6FD" ></td> <tr> <td align="center" colspan=3> </td></tr><tr> <td align="left"><b>3 樓住戶:</b>達人<img src=../icon2/00.gif><br> <b>發表時間:</b>2007-05-16 </td><td align=right>[<a href=../j2hrule.php?id=189&j2hreply=271&j2hnews=16 target=_new>檢舉</a>]</td></TR></TABLE><table width="80%" border="0" cellspacing="0" cellpadding="3"> <div align="left"> <tr><td > <br> <?php<br /> ob_start ();<br /> readfile ("http://www.30p.com.tw/House/House_Info.aspx?house_no=1041994");<br /> $data = ob_get_contents ();<br /> ob_end_clean ();<br /> $data=strip_tags($data);<br /> $data1=explode(" ",$data);<br /> $i=1;<br /> foreach($data1 as $value)<br /> {<br /> echo "$i {$value}<br />";<br /> $i++;<br /> }<br /> ?><br></div><tr><td align="right"> </td></tr> </td></tr></table></center><br> <center><table width="80% nowrap> <tr><td><table width="100%" CELLPADDING="0" CELLSPACING="2" bgcolor="#CEE6FD" ></td> <tr> <td align="center" colspan=3> </td></tr><tr> <td align="left"><b>4 樓住戶:</b>老貓<img src=../icon2/00.gif><br> <b>發表時間:</b>2007-08-27 </td><td align=right>[<a href=../j2hrule.php?id=245&j2hreply=271&j2hnews=16 target=_new>檢舉</a>]</td></TR></TABLE><table width="80%" border="0" cellspacing="0" cellpadding="3"> <div align="left"> <tr><td > <br> <br /> <?php<br /> ob_start ();<br /> readfile ("http://www.591.com.tw/rent-detail-6166.html");<br /> $data = ob_get_contents ();<br /> $want = array("聯 絡 人","E- mail","行動電話","固定電話");<br /> $data = ob_get_contents ();<br /> ob_end_clean ();<br /> $body=ereg_replace( "[\"']?", "", $data);<br /> $body=str_replace("5 BR","5",$body);<br /> preg_match_all ('/<span class=style(\d+)>(.*)<\/span><\/td>/isU', $body, $matches);<br /> $total=count($matches[1]);<br /> for($i=0;$i<$total;$i++){<br /> $style = $matches[1][$i];<br /> if ($style == 10 || $style == 7 ) {<br /> $style2 = $matches[1][$i+1];<br /> if ($style2 == 5 ) {<br /> $key = strip_tags($matches[2][$i]);<br /> $value = strip_tags($matches[2][$i+1]);<br /> if (in_array($key, $want) )<br /> printf("%s:%s\n",$key,$value);<br /> <br /> $i++;<br /> }<br /> }<br /> }<br /> <br /> <br /> ?><br /> <br></div><tr><td align="right"> </td></tr> </td></tr></table></center><br> <center><table width="80% nowrap> <tr><td><table width="100%" CELLPADDING="0" CELLSPACING="2" bgcolor="#CEE6FD" ></td> <tr> <td align="center" colspan=3> </td></tr><tr> <td align="left"><b>5 樓住戶:</b>晴晴<img src=../icon2/00.gif><br> <b>發表時間:</b>2007-08-29 </td><td align=right>[<a href=../j2hrule.php?id=246&j2hreply=271&j2hnews=16 target=_new>檢舉</a>]</td></TR></TABLE><table width="80%" border="0" cellspacing="0" cellpadding="3"> <div align="left"> <tr><td > <br> $data = file_get_contents ("http://www.591.com.tw/rent-detail-7432.html");<br /> $pattern = '/<span class=[\'"]style(10|5)[^"\']*[\'"]>([^<]*)<\/span>/isU';<br /> $want = array("聯絡人","E-mail","行動電話","固定電話");<br /> preg_match_all($pattern,$data,$matched);<br /> <br /> foreach($matched[2] as $key=>$value){<br /> $matched[2][$key] = preg_replace('/\s/','',$matched[2][$key]);<br /> if(in_array($matched[2][$key],$want)){<br /> $result[$matched[2][$key]] = $matched[2][$key+1];<br /> }<br /> }<br /> $table = 'info';<br /> $query = sprintf("INSERT INTO %s (`聯絡人`,`E-mail`,`行動電話`,`固定電話`) VALUES ('%s','%s','%s','%s')",<br /> $table,<br /> $result['聯絡人'],<br /> $result['E-mail'],<br /> $result['行動電話'],<br /> $result['固定電話']<br /> );<br /> echo $query;<br /> <br /> if(mysql_query($query)){<br /> echo "<center><H1> 完成</h1> </center>";<br /> }else{echo "<p> 資料庫錯誤 </p>";}<br /> <br /> //有時候正規會出問題!不能用的時候請檢查正規表示式<br /> //如果無法寫入資料庫直接檢查sql語法即可<br /> <br /> <br></div><tr><td align="right"> </td></tr> </td></tr></table></center><br> <center><table width="80% nowrap> <tr><td><table width="100%" CELLPADDING="0" CELLSPACING="2" bgcolor="#CEE6FD" ></td> <tr> <td align="center" colspan=3> </td></tr><tr> <td align="left"><b>6 樓住戶:</b>鴨子<img src=../icon2/00.gif><br> <b>發表時間:</b>2008-03-15 </td><td align=right>[<a href=../j2hrule.php?id=263&j2hreply=271&j2hnews=16 target=_new>檢舉</a>]</td></TR></TABLE><table width="80%" border="0" cellspacing="0" cellpadding="3"> <div align="left"> <tr><td > <br> $txt = iconv("big5", "utf-8",file_get_contents("http://www.520house.com.tw/index-inquiry1-txt.asp?Key=35053&page="));<br /> $txt = str_replace("\r\n","",$txt);<br /> $txt = str_replace("<","",$txt);<br /> $txt = str_replace(">","",$txt);<br /> $txt = str_replace("\"","",$txt);<br /> $txt = str_replace(" ","",$txt);<br /> $txt = trim($txt);<br /> <br /> <br /> <br /> <br /> $re = array ("(地址:)/div/tdtdcolspan=3(.*?)/td","(建物:)/div/tdtdwidth=52%(.*?)/td","(用途:)/div/tdtdwidth=25%(.*?)/td","(所在樓層/總樓層)/div/tdtdcolspan=(.*?)/td"<br /> ,"(總價:)/div/tdtdcolspan=3(.*?)/td","(管理員:)/div/tdtd有/td","(管理費:)/div/tdtd(.*?)/td","(坪數:)/div/tdtd(.*?)/td","(電梯:)/div/tdtd(.*?)/td","(房屋格局:)/div/tdtd(.*?)/td","(屋齡:)/div/tdtd(.*?)/td","(家具:)/div/tdtdcolspan=3(.*?)/td","(詳細說明:)/div/tdtdcolspan=3(.*?)/td","(聯絡人:)/div/tdtd(.*?)/td","(身分:)/div/tdtd(.*?)/td","(市話:)/div/tdtd(.*?)/td","(手機:)/div/tdtd(.*?)/td","(電子信箱:)/div/tdtdcolspan=3(.*?)/td");<br /> <br /> <br /> <br /> $header = array();<br /> $content = array();<br /> foreach($re as $k => $v){<br /> preg_match_all("|$re[$k]|i",$txt,$tmp);<br /> array_push($header,$tmp[1][0]);<br /> array_push($content,$tmp[2][0]); <br /> }<br /> <br /> <br /> <br /> foreach($header as $k=>$v){<br /> echo $v.str_replace("br","<br>",$content[$k])."<BR>";<br /> }<br /> <br /> 幫你寫一個妳測試看看如果你的頁面本身是BIG5請將下面<br /> $txt = iconv("big5", "utf-8",file_get_contents("http://www.520house.com.tw/index-inquiry1-txt.asp?Key=35053&page="));<br /> 改成<br /> $txt = file_get_contents("http://www.520house.com.tw/index-inquiry1-txt.asp?Key=35053&page="); <br /> <br></div><tr><td align="right"> </td></tr> </td></tr></table></center><br> <br><hr size=1> 共 6 人回應  選擇頁數 <a href=j2h-271-0.html>【第1 頁】 </a> <p> <center><form method=post action=reply_post.php?id=271 onSubmit="return(check())" name="form1"> <script language="javascript"> form1.j2h.value=""; form1.j2h5.value=""; function check() { var str_pattern=/^.{2,34}$/; if(form1.j2h.value.length < 2) { alert("請輸入姓名 !!"); return(false); } if(form1.j2h.value.match(/[12~#$<%^┐*∼§☆°+★~ ̄▽ ̄.≠ˇㄟ@=♂×,.0Oo├﹏☆〃'"\﹋\&*\/\\@!]/)){alert("請正確填寫姓名,請勿使用任何符號或敷衍字\n如果繼續張貼將會被列為黑名單"); return false} var die = ["白痴","白ㄔ","白爛","花癡","喜憨","媽的","哩娘","那ㄇ爛","白目","北七","屌屁","濫遊戲","嘴賤","屌屁","智障","他媽的","廢渣","廢物","機掰","雞掰","靠北","嫩啦","有種來談判","有種出來說","爛片","無三小路用","濫到爆","肉腳","靠邀","殺小","吃屎","阿拉斯加","靠背","電愛","破麻","幹你","幹妳","幹林","幹李","幹幹幹","機掰","幹過了","不給上","給虧嘛","欠人插","啥小","欠幹","屁事","醜到爆","難看死","搞在一起","鬼一樣","長的醜","都很濫","靠你媽","瞎了狗眼","你他媽","死怪物","醜八怪","虎人","智障","嗆聲","幹架","白吃","修幹","去死","敗類","度濫","人渣","插我","雞八","靠杯","啟智","靠逼","狗屌","狗幹","幹砲","吃大便","打奶砲","打手槍","打泡","攬較","嫩逼","人妖","娘砲","下賤","低能兒","好娘","馬ㄉ","弱智","低能","智缺","死一死","攬叫","吃大便","啥鳥","拎北","開始幹她","機八","他媽ㄉ","腦殘","想幹他","別丟臉","爛死了","想嘗試愛愛","幹死妳","想做愛","賤炮","孬種","俗辣","沙小","白木","智帳","臭嘴","孬種","想愛愛","教我","想練","跳舞","不會","地板","不爽","只會","風車","我","妳","他","你","就","請問","這","樣","堆","的","想學","看","不","下","去","了","小蛙","沒","一起","上帝","勃起","j2h","JXH","專砲腦狗","懶趴","笑話","練舞","一個","臭基基","笑死","糙哩","每天","打槍","<"]; for(var i=0;i < die.length;i++) if(form1.j2h.value.toLowerCase().replace(/ /gi, "").indexOf(die[i])!=-1) { alert("名稱中含有疑似不雅或是被禁止使用的名稱或敷衍字,\n請移除此 '"+ die[i] +"' 文字,請正確填寫名稱,\n如果繼續張貼將會被列為黑名單"); return(false);} if(form1.j2h5.value.length < 5) { location="index.php"; return(false); } if(form1.j2h5.value.match(/[ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄧㄨㄩㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦ]/)){alert("留言請勿使用任何注音文或是火星文\n如果繼續張貼將會被列為黑名單"); return false} var jstop2 = ["求歌名","什麼歌","音樂叫什麼","歌名"]; for(var i=0;i < jstop2.length;i++) if(form1.j2h5.value.toLowerCase().replace(/ /gi, "").indexOf(jstop2[i])!=-1) { alert("J2H為分享平台,嚴禁張貼求檔求歌名主題\n如果繼續張貼將會被列為黑名單"); location="http://www.j2h.tw/"; return(false); } var jstop = [".exe","yahoo.com","kimo.com","wretch.cc","tinyurl.com","@","<script"]; for(var i=0;i < jstop.length;i++) if(form1.j2h5.value.toLowerCase().replace(/ /gi, "").indexOf(jstop[i])!=-1) { alert("留言內容中含有被禁止張貼的網址,\n請移除此 '"+ jstop[i] +"' 網址,\n如果是要張貼影片請用'連結網址方式',\n請先至新手討論區那邊學習或測試,那有相關教學\n如果繼續張貼將會被列為黑名單"); return(false); } var spam = ["白痴","白癡","白爛","孬種","俗辣","三八","長的醜","白ㄔ","沙小","白木","智帳","北爛","花癡","喜憨","媽的","馬的","哩娘","那ㄇ爛","白目","北七","屌屁","濫遊戲","嘴賤","屌屁","智障","他媽的","廢渣","廢物","機掰","雞掰","靠北","嫩啦","有種來談判","有種出來說","爛片","無三小路用","濫到爆","肉腳","靠邀","殺小","吃屎","阿拉斯加","靠背","電愛","破麻","幹你","幹妳","幹林","幹李","幹幹幹","機掰","幹過了","不給上","給虧嘛","欠人插","啥小","欠幹","屁事","醜到爆","難看死","搞在一起","鬼一樣","長的醜","都很濫","靠你媽","瞎了狗眼","你他媽","死怪物","醜八怪","虎人","智障","嗆聲","幹架","白吃","修幹","去死","敗類","度濫","人渣","插我","雞八","靠杯","啟智","靠逼","狗屌","狗幹","幹砲","吃大便","打奶砲","打手槍","打泡","攬較","嫩逼","人妖","娘砲","下賤","低能兒","好娘","馬ㄉ","弱智","低能","智缺","死一死","攬叫","吃大便","啥鳥","拎北","開始幹她","機八","他媽ㄉ","腦殘","想幹他","別丟臉","爛死了","想嘗試愛愛","幹死妳","靠爸","賤胚","賤炮","臭嘴","屁話","不要臉","白幕","爛人","嫩B","靠腰","砲友","招人","八千下","狼牙","基掰","糙你","<iframe"]; for(var i=0;i < spam.length;i++) if(form1.j2h5.value.toLowerCase().replace(/ /gi, "").indexOf(spam[i])!=-1) { alert("留言內容中含有疑似不雅的文字或是被禁止的文字,\n請移除不雅 '"+ spam[i] +"' 的文字,\n請禮貌已對請勿有任何辱罵批評、挑釁、人身攻擊等字眼,\n以免被列為黑名單"); return(false); } var dirty = ["客源網","寄給我","傳給我","............","____/洗/ ","999999","1樓","location.replace","私服","嘴砲","嘴炮","嘴泡","炮文","嘴巴最強","砲你","炮你","泡你"]; for(var i=0;i < dirty.length;i++) if(form1.j2h5.value.replace(/ /gi, "").indexOf(dirty[i])!=-1) { location="index.php"; return(false); } var dirty = ["lovergirlever.com","live173.com?","money.tw","[/url]","tww633","汽車借錢","機車借錢","當舖","你找我找他","u-mao","love5955.com","wscs191010","pp2.idv.tw","ppt.cc","is.gd","weebly.com","茶坊","dd93751","EM.crew.tw ","yodidi.com","wagn886","yhoosec","sallyas1990","xolove525","xolove521","yudidi.com","vions.net","qiqi7789","大和賞","xolove","現金消費","llxllx111","不轉帳","不刷卡","bule88088","love_520ve","baydu520","phoebe15840","ck077","goo.gl","在家兼職","now.to","網路專兼職","電腦操作網路宣傳","九十天免費試用","HBEE","mikehang63","ftp.cc","xiaodie91","staiwan.com","abc173.com","blogspot.com","fashion3c.url.tw","ligsystem.com","twmis.net","neopets.com","so-ya4","無碼","情色網","av808.com","hjchung.tw","slime.com.tw","vovo2000.com","Hung-Ya.com","lookm.com","hisyy.com","msi-team.com","homework123.com","twcam.com","qoo.av-city","arx.myweb.hinet.net","sogood.why.to","a href","dvd888.com","neopets.com","kan120.com","x-adam.com","hung-ya.com","gigicry.com","msi.168.lv","dy8.com","2sextv.com","嘗鮮專線","現金收費","kelly_shop","批發切貨","zxcvb001cm","moneymine.net","成人貼圖","兼職做援","全套服務","哥哥約愛","weilon.no-ip.com","[/url]","[url=","top20free.com","breaki77ing","c329646","xyz22.com","snow258.com","love5955.com","5280344","qwe3300923","nini9595","besttuboonline.com","srvo.idv","eyny.com","besttuboonline.com","his_funky_style","dancerhiphop","coolgo.com","libb.co","xin-yuan.tw","27756599","567pan.com","boy4628241","fashion3c","0938009789","besttuboonline.com","yuonuom.com","weebly.com","tw9m.com","蜻蜓飛舞","yunupload.net","jolin578","0909873168","live173.com","美女視訊",".com","http"]; for(var i=0;i < dirty.length;i++) if(form1.j2h5.value.replace(/ /gi, "").indexOf(dirty[i])!=-1) { location="http://www.j2h.tw/bbs/bombersuper.php"; return(false); } if(form1.j2h4.value!='' && form1.j2h10.value=='') { alert("請務必選擇正確連結檔案!"); return(false); } var dirty = ["http://www.wretch.cc/album/","http://www.wretch.cc/blog/",".exe","yahoo.com","C:","care-you","j2h.tw",".html",".htm","@","www.soo-easy.com/shaonv.mp3"]; for(var i=0;i < dirty.length;i++) if(form1.j2h4.value.indexOf(dirty[i])!=-1) { alert("連結網址方式錯誤,\n新手討論區有相關教學請至那邊學習或測試,\n以免被版主列為黑名單"); location="http://www.j2h.tw/bbs/bbs14/j2h.php?id=3378"; return(false); } return(true); } </script> <table width="90%" height=65 border="1" cellpadding=1 cellspacing=0 bordercolorlight=#346783 bordercolordark=#FFFFFF bgcolor="#F0F9FF"> <tr align="center"> <input type="hidden" name="username" value=""> <td width="14%" ALIGN="left" VALIGN="TOP" NOWRAP>姓名:</td> <td align="left" colspan=3><input NAME="j2h" MAXLENGTH="16" SIZE="60" value=''> </td> </tr> <tr align="center"> <td ALIGN="left" VALIGN="TOP" NOWRAP>佈告內容:</td> <td align="left" colspan=3> <textarea name="j2h5" ROWS="15" COLS="80" ></textarea> </td> </tr> <tr align="center"> <td ALIGN="RIGHT" VALIGN="TOP" NOWRAP colspan="4"> <p align="center"><br> <input type=submit value='確定發言' onClick="this.disable=true;"> </td></tr></table></form> </center></body></html>