Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 解析任何url中的内容并以原始形式显示在div中_Javascript_Php_Html_Dom - Fatal编程技术网

Javascript 解析任何url中的内容并以原始形式显示在div中

Javascript 解析任何url中的内容并以原始形式显示在div中,javascript,php,html,dom,Javascript,Php,Html,Dom,我以这种方式阅读网页内容: $doc->loadHTMLFile($url); libxml_clear_errors(); $xpath = new DOMXPath($doc); // PLease dont suggest file_get_Content($url) I cant use due to some issue foreach($xpath->query("//script") as $script) { $script->parentNo

我以这种方式阅读网页内容:

$doc->loadHTMLFile($url);
libxml_clear_errors();
$xpath = new DOMXPath($doc);      // PLease dont suggest file_get_Content($url) I cant use due to some issue
foreach($xpath->query("//script") as $script) {
    $script->parentNode->removeChild($script);
}
$textContent = $doc->textContent;
然后

echo$textContent

我将此页面的响应放在一个div中,以显示
$textContent
的结果

但整个文本显示在一个段落中。不像往常那样在页面上。 我试过了
之所以只获取HTML的内部文本(即textContent),是因为textContent就是这样工作的。相反,您希望通过将代码更改为如下所示来获取节点的innerHTML:


现在,您可以随意回显
$innerHTML
,它将包含所有HTML。

显示您的响应output@NathanSrivi:我添加了响应输出!请不要预先贴标签response@NathanSrivi:这是我的代码,请查看:谢谢,但现在它显示了所有内容,包括图像、按钮和其他内容。我只想显示文本内容!我认为,
$test=preg\u replace(“/[^a-zA-Z]+/”,“,html\u entity\u decode($text))将帮助我。但是在这里如何包含新行字符?请将您的HTML输入文件发布到pastebin并在这里发布链接。
Investor Herd Dynamics Want to start a startup? Get funded by Y Combinator. August 2013The biggest component in most investors'\'' opinion of you is the opinion of other investors. Which is of course a recipe for exponential growth. When one investor wants to invest in you, that makes other investors want to, which makes others want to, and so on.Sometimes inexperienced founders mistakenly conclude that manipulating these forces is the essence of fundraising. They hear stories about stampedes to invest in successful startups, and think it'\''s therefore the mark of a successful startup to have this happen. But actually the two are not that highly correlated. Lots of startups that cause stampedes end up flaming out (in extreme cases, partly as a result of the stampede), and lots of very successful startups were only moderately popular with investors the first time they raised money.So the point of this essay is not to explain how to create a stampede, but merely to explain the forces that generate them. These forces are always at work to some degree in fundraising, and they can cause surprising situations. If you understand them, you can at least avoid being surprised.One reason investors like you more when other investors like you is that you actually become a better investment. Raising money decreases the risk of failure. Indeed, although investors hate it, you are for this reason justified in raising your valuation for later investors. The investors who invested when you had no money were taking more risk, and are entitled to higher returns. Plus a company that has raised money is literally more valuable. After you raise the first million dollars, the company is at least a million dollars more valuable, because it'\''s the same company as before, plus it has a million dollars in the bank. [1]Beware, though, because later investors so hate to have the price raised on them that they resist even this self-evident reasoning. Only raise the price on an investor you'\''re comfortable with losing, because some will angrily refuse. [2]The second reason investors like you more when you'\''ve had some success at fundraising is that it makes you more confident, and an investors'\'' opinion of you is the foundation of their opinion of your company. Founders are often surprised how quickly investors seem to know when they start to succeed at raising money. And while there are in fact lots of ways for such information to spread among investors, the main vector is probably the founders themselves. Though they'\''re often clueless about technology, most investors are pretty good at reading people. When fundraising is going well, investors are quick to sense it in your increased confidence. (This is one case where the average founder'\''s inability to remain poker-faced works to your advantage.)But frankly the....
$doc->loadHTMLFile($url);

libxml_clear_errors();

$xpath = new DOMXPath($doc);      // PLease dont suggest file_get_Content($url) I cant use due to some issue

foreach($xpath->query("//script") as $script) {
    $script->parentNode->removeChild($script);
}

$innerHTML = '';

foreach ($doc->childNodes as $child)
{
    $innerHTML .= $child->ownerDocument->saveHTML($child);
}