亚洲精品久久久久久第一页-人妻少妇精彩视品一区二区三区-91国产自拍免费视频-免费一级a在线播放视频正片-少妇天天日天天射天天爽-国产大屁股喷水视频在线观看-操美女骚穴抽插性爱视频-亚洲 欧美 中文字幕 丝袜-成人免费无码片在线观看

php解析html的方法 php獲取html標(biāo)簽內(nèi)容


php解析html的方法 php獲取html標(biāo)簽內(nèi)容

文章插圖
PHP獲取指定網(wǎng)頁(yè)的HTML代碼并執(zhí)行輸出 , 這個(gè)方法主要是將所要或取目標(biāo)的URL地址的網(wǎng)站中獲取相關(guān)內(nèi)容到自己的網(wǎng)頁(yè)中 。代碼如下:
<?php $srcurl = "所要截取目標(biāo)的URL地址"; $handle = fopen($srcurl,"rb"); $content = fread($handle,10240000); $start_position=strpos($content,'截取內(nèi)容開始代碼A'); $start_position=$start_position+strlen('截取內(nèi)容開始代碼A'); $end_position=strpos($content,' 截取內(nèi)容結(jié)束代碼C'); $length=$end_position-$start_position; $content=substr($content,$start_position,$length); echo 'document.write("'.$content.'")'; ?>這樣就可以截取所需的內(nèi)容B 。追后賦予$content , 我在最后加上了echo ‘document.write為的是這樣就生成了JS代碼 。直接就成了JS代碼可直接在我想需要此內(nèi)容的地方用JS調(diào)用顯示 。這個(gè)你用php是不能獲得的 , 它又不是通過get或post提交的 可以給你的<td>一個(gè)id , 然后通過document.getElementByIdx_x_x_x(“name”).innerHtml就可以獲得了
代碼庫(kù)
導(dǎo)入指定網(wǎng)站或頁(yè)面代碼如下:
HP 獲取指定網(wǎng)站、網(wǎng)頁(yè)、URL 的 <head> 標(biāo)題:獲取網(wǎng)頁(yè)的標(biāo)題:
<? $url = 'http://www.*****.com/'; $lines_array = file($url); $lines_string = implode('', $lines_array); eregi("<head>(.*)</head>", $lines_string, $head); echo $head[0]; ?>HP 獲取網(wǎng)頁(yè)的 Html 源代碼輸出并執(zhí)行:<?php$lines = file('http://www.******.com/');foreach ($lines as $line_num => $line) {echo $line;}?>獲取網(wǎng)頁(yè)Html源代碼輸出并執(zhí)行2:<?phpecho file_get_contents("http://www.******.com/");?>PHP 獲取指定網(wǎng)站、網(wǎng)頁(yè)、URL 的 Html 源代碼:獲取網(wǎng)頁(yè)Html源代碼:
<?php$lines = file('http://www.*******.com/');foreach ($lines as $line_num => $line) {echo "Line <b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />n";}?>特定網(wǎng)頁(yè)的特定代碼段
<?php $url = "http://******.****.com/a/20110428/005344.htm"; $contents = file_get_contents($url); //如果出現(xiàn)中文亂碼使用下面代碼 //$getcontent = iconv("gb2312", "utf-8",$contents); //echo $contents; $from="<div id="Cnt-Main-Article-QQ"><P style="TEXT-INDENT: 2em">";$end="</div>";$q=cut($contents, $from, $end);echo $q;function cut($file,$from,$end){ $message=explode($from,$file); $message=explode($end,$message[1]); return $message[0]; } ?>PHP 查找、判斷字符串在另一個(gè)字符串中是否存在:
<?phpif(stristr("www.****.com", "****.com")) { echo "查詢關(guān)鍵詞"; }?>


    以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問題,請(qǐng)您及時(shí)就醫(yī)或請(qǐng)專業(yè)人士給予相關(guān)指導(dǎo)!

    「愛刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對(duì)您有所幫助: