我从一个网址解析得很好,但是如何在同一个文件中添加第二个源网址。
e.g。
$html = file_get_html('http://google.com');
对于一个网址,但如何添加第二个源并使其与“echo”功能一起使用?
由于
答案 0 :(得分:0)
我认为大多数解析器都不允许您添加无效的重复标记,例如<head>
和<body>
。您可以尝试首先解析两个URL并提取它们的主体:
$page1 = file_get_html('url1');
$body1 = $page1->find('body');
$page2 = file_get_html('url2');
$body2 = $page2->find('body');
然后将它们组合在一起并解析:
$body1 = $body1->plaintext;
$body2 = $body2->plaintext;
$bodies = str_get_html($body1.$body2);