从外部页面提取元素的内容 [英] Extracting the content of an element from an external page
问题描述
我们引用了一个网站重建,它涉及到我们采用当前的网站,为它做一个新的设计,然后在Business Catalyst(Adobe的内容管理系统)中重建它。
We are quoting on a website rebuild that involves us taking a current website, doing a new design for it and then rebuilding it within Business Catalyst (Adobe's Content Management System).
不幸的是,当前的网站从我所假设的MySQL表中获取信息(因为该网站是用PHP编写的),Business Catalyst不支持使用服务器端语言。
Unfortunately the current website draws information from what I'm assuming to be a MySQL table (as the site is written in PHP) and Business Catalyst doesn't support the use of server-side languages.
有没有一种方法可以从Web上的远程页面提取HTML段,并使用非服务器端脚本(可能使用JQuery)将其显示在新网站上?
Is there a way that I can extract a segment of HTML from a remote page on the web and display it on the new website using non server-side script, maybe with JQuery?
以下是我提出的一些建议,以及为什么他们不适合这种情况的原因:
Here are some suggestions I have put forward and the reasoning behind why they aren't viable for this situation:
- iFrame - 首先想到了这一点,但我不确定是否可以:
a。样式加载的HTML
b。我想要捕获的内容位于页面的中心 - 我不知道如何渲染iFrame的内容,从该容器的左上角开始,而不是页面的左上角。
< - 将当前MySQL表格的内容导出到Excel中,然后将其导入到Business Catalyst中 - 因为公司在他们的计算机上安装了与其连接的库存管理软件数据库,意味着它每天更新10次以上。
任何建议都会很棒。
如果任何人都可以 tag
这个问题对我来说会更好,因为我有有些麻烦。
If anyone can tag
this question better for me that would appreciated as I'm having some trouble.
推荐答案
您可以使用jQuery的 load()
函数将外部页面(甚至是另一页上的特定div)的内容加载到当前页面上的div ,就像这样:
You can use jQuery's load()
function to load content from an external page (even a specific div on another page) into a div on the current page, like so:
$("#load_content_in_this_div").load("page.html #div_to_pull_from");
这会载入从 #div_to_pull_from
div page.html
放入当前页面的 #load_content_in_this_div
div。
This will load content pulled from the #div_to_pull_from
div on page.html
into the #load_content_in_this_div
div on the current page.
至于从另一个域的页面提取内容,这个插件应该可以做到。
As for pulling content from pages on another domain, this plugin should do the trick.
这篇关于从外部页面提取元素的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!