使用simple_html_dom提取文档类型 [英] Extract doctype with simple_html_dom

查看:266
本文介绍了使用simple_html_dom提取文档类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 simple_html_dom 来解析网站。
是否可以提取文档类型?

I am using simple_html_dom to parse a website. Is there a way to extract the doctype?

推荐答案

您可以使用 file_get_contents 函数从网站获取所有HTML数据。
例如

You can use file_get_contents function to get all HTML data from website. For example

<?php
   $html = file_get_contents("http://google.com");
   $html = str_replace("\n","",$html);
   $get_doctype = preg_match_all("/(<!DOCTYPE.+\">)<html/i",$html,$matches);
   $doctype = $matches[1][0];
?>

这篇关于使用simple_html_dom提取文档类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆