开发者

open external url in div

i want to load contents of external url l开发者_C百科ike (http://www.google.com) into div,

i the way which will readable by search engine crawl.

in any one of (jquery / ajax / php )

Thanks


As others have mentioned, iFrame content won't be indexed, nor will content loaded with JavaScript. This is a good thing, though – it prevents you from getting docked for having duplicate content. As a technical example, though....

<?
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
echo $result;
?>

Curl is MUCH better at this than file_get_contents and it's faster than using sockets too (there is overhead associated with opening and reading sockets in PHP...libcurl does it at a closer-to-native level, which makes it faster overall...I've tested this significantly).


Search indexing spiders typically work by viewing the "static" portions of your site. Any content loaded via JavaScript techniques (ajax, jQuery, etc.) will not work.

You can, however, use PHP to load an external site by using the file() function.


If you want to actually display that website, you need to be using an iframe.

If you want to scrape the content and then display it yourself, there's tons of ways. cURL, file_get_contents(), all will do the trick.


This one open the whole page on the div called this_div.

ANSWER1: $('this_div').load("www.google.com");

This one open the page and load the specific div of the url with a div called external to this_div.

ANSWER1: $('this_div').load("www.sample.com #external");

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜