开发者

How to automatically update a site with some other site contents.?

How to upda开发者_运维问答te a site with some other site contents that is getting refreshed often (may be twice in a minute)?


What you're doing is called scraping a website. Try googling on that. Pay particular attention to the laws around it. If you're benefiting the company you're scraping, they'll probably help you; if you're not, they'll probably sue you.


$.load() is your friend. The following JQuery-function call will replace the current value of element (e.g. div) with the id "result" with the content of page "ajax/test.html".

$('#result').load('ajax/test.html');

or with an additional success handler:

$('#result').load('ajax/test.html', function() {
  alert('Load was performed.');
});

if you would like to call one of these function every n seconds, use the following code:

setInterval(function() {
  // wrap one of the above calls
}, <n>000);

edit: for a cross-domain-solution, you can write a proxy page on your site which, upon call, loads the content of the 'other site' and echoes it.

Snippet available here: http://www.daniweb.com/code/snippet216729.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜