如何从外部URL获取html源代码 [英] How to get html source code from external url

查看:384
本文介绍了如何从外部URL获取html源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从外部网页获取html源代码?

How can I get html source code from an external web page?

类似于: getHtml('http://google.com');

我试图使用以下方法获取iframe的内容: $(#frame)。contents()。find(html); ,但如果在我的情况下网页没有html标签,只需1行文字。我不能用php file_get_contents()来做,因为它不会保留会话数据。

I've tried to get content of iframe using: $("#frame").contents().find("html");, but if in my case the webpage doesn't have html tags, just 1 line of text. I can't do it with php file_get_contents() because it doesn't keep session data.

推荐答案

跨域?没有服务器进程是不可能的。如果你在Windows上并且可以使用HTA,你可以使用iframe

Cross domain? not possible without a server process. If you are on windows and can use HTA you can use the iframe

这篇关于如何从外部URL获取html源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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