0

Bear with me, I'm not a programmer.

Is there a JavaScript or software or something that can take a chunk of HTML from a page that sits in one domain, and use it/parse it in another page that sits in a different domain?

Let me make a quick example:

On domain A - a.com is this HTML:

<div>
  <ul>
    <li>Item 1</li>
    <li>Item 1</li>
    <li>Item 1</li>
  <ul>
  <p>Pargraph info...</p>
  <table>
    ...
  <table>
</div>

On domain B -- b.com I would like to use only the <table> from domain a.com

Is this doable?

Any help on this is greatly appreciated.

Thanks.

4

1 回答 1

1

跨域资源共享是可行的。见:http ://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing

那里的问题是您需要能够配置您从中请求数据的站点以接受请求的来源。除非您拥有该服务器,否则基本上不会发生。

您可以研究的另一种方法是编写一个程序来从您想要的页面中提取 HTML。但是您并没有在您的网站中使用 HTML,您只是在计算机上的程序中访问它。如果您只想为自己拉下表格,而不是将其用作另一个网站的一部分,这将是一个好方法。

于 2012-12-07T03:05:41.863 回答