您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP网页实用小功能(一)

2025/4/10 9:11:39发布46次查看
从网页中提取关键字
$meta = get_meta_tags('http://www.aseoe.com/');    $keywords = $meta['keywords'];    // split keywords    $keywords = explode(',', $keywords );    // trim them    $keywords = array_map( 'trim', $keywords );    // remove empty values    $keywords = array_filter( $keywords );         print_r( $keywords );  
效果如下
查找页面上的所有链接
使用dom,你可以轻松从任何页面上抓取链接,代码示例如下:
$html = file_get_contents('http://www.example.com');         $dom = new domdocument();    @$dom->loadhtml($html);         // grab all the on the page    $xpath = new domxpath($dom);    $hrefs = $xpath->evaluate(/html/body//a);         for ($i = 0; $i $hrefs->length; $i++) {           $href = $hrefs->item($i);           $url = $href->getattribute('href');           echo $url.'
';    }    已测试 完全可以实现。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product