source:' of an external page?
我尝试使用<a href="view-source:google.com">External Source</a>
但这只是返回一个断开的链接。
The schema/protocol http:
is missing:
<a href="view-source:http:google.com">External Source</a>`
Test with the scURIple (scriple):
data:text/html;charset=utf-8,<html><a href="view-source:http:google.com">External Source</a></html>
If you're just going to need the HTML source of a webpage, and not anything else, and you're willing to use a server-side language, there is the option of using curl
, file_get_contents
, or Simple HTML DOM to get the HTML of a website, and then display that on your own page between <code></code>
or <pre></pre>
tags. This would look something like this in PHP
include("simplehtmldom.php");
$html=file_get_html($url);
echo "<pre>$html</pre>;
Obviously this should be formatted or prettyprinted. Take a look at Google Code prettifier to do this. If you want to get the source of your own page, you could use Javascript, and do this:
var html=document.documentElement.outerHTML;
I'm not sure how that would work for fetching external pages, but you could try an iframe
for that, like this
document.getElementById('frame').contentWindow.documentElement.outerHTML;
As an alternative to outputting everything in a <pre>
block, consider returning a different content type. In your response headers:
Content-Type: text/plain
Then, you can simply return the HTML content and it will be displayed as plain-text in the browser.
链接地址: http://www.djcxy.com/p/17914.html上一篇: 在远程机器上总是运行virtualenv的最佳方式?
下一篇: 来源:'的外部页面?