How To Scrape Content From Other Sites Using Jquery?
Solution 1:
Using Cross-Domain-Ajax JQuery Plugin you can do it like this:
$.ajax({
url: 'http://news.bbc.co.uk',
type: 'GET',
success: function(res) {
var headline = $(res.responseText).find('a.tsh').text();
alert(headline);
}
});
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.
Solution 2:
You can't. The Same Origin Policy prevents this. To do this you need to do it on a server using XMLHTTP.
Solution 3:
I suggest you use the curl module in PHP to access the news site's rss feed to collect the news you want to embed.
Setup a cron process to periodically download the RSS feed to local storage and convert it into a format you can use for your site. This will help to keep the load on the server down as your gathering the news once instead of every time the page is accessed.
Solution 4:
You can do Data scraping using CURL in PHP instead of jquery You can see the blog for Data scraping using CURL in PHP: http://www.codefire.org/blogs/item/data-scraping-using-curl-in-php.html
Post a Comment for "How To Scrape Content From Other Sites Using Jquery?"