在尝试学习和使用Goutte搜索网站的描述时,它确实检索文本,但删除了所有标记(即<br><b>)。是否有方法检索div中所有文本的值,包括html标记?还是有一种更简单的替代方法能让我具备这种能力?
<?php
require_once "vendor/autoload.php";
use Goutte\Client;
// Init. new client
$client = new Client();
$crawler = $client->request('GET', "examplesite.com/example");
// Crawl response
$description = $crawler->filter('element.class')->extract('_text');
?>发布于 2018-03-08 10:12:19
您可以使用html()功能
html
像这样
$descriptions = $crawler->filter('element.class')->each(function($node) {
return $node->html();
})在您可以使用strip_tags PHP函数清理它之后
http://php.net/manual/fr/function.strip-tags.php
https://stackoverflow.com/questions/48090883
复制相似问题