问题描述
我正在用PHP进行一个NEWS站点项目,对于这个项目,我想使用jQuery / JavaScript从其他NEWS站点获取内容。 jQuery中有没有从其他域名中删除内容的函数?
I am doing a NEWS site project in PHP and for this project I want to fetch content from other NEWS sites using jQuery/JavaScript. Is there any functions in jQuery which scrape content from other domain names?
而且我也不想使用庞大的服务器CPU,因为它是一个大学服务器。使用jQuery来删除内容会使用巨大的CPU吗?
And also I don't want to use huge server CPU, since it is a college server. Does using jQuery for scrapping content use huge CPU?
在Stack Overflow中我读到了关于 jQuery.get()
的函数,是否可以使用此功能从其他网站上抓取内容?
In Stack Overflow I read about jQuery.get()
function, is it ok to use this function to scrape content from other sites?
推荐答案
使用你可以这样做:
$.ajax({
url: 'http://news.bbc.co.uk',
type: 'GET',
success: function(res) {
var headline = $(res.responseText).find('a.tsh').text();
alert(headline);
}
});
他们劫持ajax方法使用获取html并将其作为JSON返回,然后将其用作字符串来刮取数据。有关详细信息,请查看。
they're hijacking the ajax method to use YQL to grab the html and return it as JSON, then use that as a string to scrape the data. check out the Jquery Cross-domain Ajax Guide for more info.
这篇关于如何使用jQuery从其他网站抓取内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!