我有一个xml文件,其中将包含几个内部html页面的链接。我正在使用HTML DOM来获取这些链接并在表格中显示这些链接。这些链接是简单的html链接,没有参数。这些html页面驻留在服务器中。
我的问题是,当我在站长工具中使用fetch as google的时候。google正在获取javascript,而不是填充的表。谷歌会抓取并索引这些链接吗?我想确保这里链接的这些页面将被索引...请指导我解决这个问题。也让我知道,如果有一个更好的方式来显示内容从xml,以便谷歌抓取这些链接。
<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","/jobs/jobs.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write('<table id="example">');
document.write('<thead><tr><th>Job ID</th><th>Job Title</th><th class=\"mobexcl\">Location</th><th class=\"mobexcl\">Country</th><th class=\"mobexcl\">Date Posted</th><th>Status</th><th class=\"mobexcl\">View</th></tr></thead><tbody>');
var x=xmlDoc.getElementsByTagName("CD");
for (i=0;i<x.length;i++)
{
if(i%2==0){
document.write('<tr class="alt">');
}
else{
document.write('<tr class="alt1">');
}
document.write("<td>");
document.write('<a href="' + x[i].getElementsByTagName("VIEW")[0].childNodes[0].nodeValue + '">'+x[i].getElementsByTagName("JOBID")[0].childNodes[0].nodeValue+'</a>');
document.write("</td><td>");
document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
document.write("</td><td class=\"mobexcl\">");
document.write(x[i].getElementsByTagName("LOCATION")[0].childNodes[0].nodeValue);
document.write("</td><td class=\"mobexcl\">");
document.write(x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue);
document.write("</td><td class=\"mobexcl\">");
document.write(x[i].getElementsByTagName("DATE")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("STATUS")[0].childNodes[0].nodeValue);
document.write("</td><td class=\"mobexcl\">");
document.write('<a href="' + x[i].getElementsByTagName("VIEW")[0].childNodes[0].nodeValue + '">View/Apply</a>');
document.write("</td></tr>");
}
document.write("</tbody></table>");
</script>发布于 2014-03-23 09:33:21
爬虫不会在你的页面上执行脚本。
谷歌已经设计了一种方法来抓取ajax填充的站点。你可以在here上读到它。
列表中的第三项似乎适用于你的情况。
基本上,您的服务器需要创建ajax呈现的页面的HTML快照,以便google bot爬行。
Google还提供了测试此设置的工具。
HTH。
https://stackoverflow.com/questions/22585775
复制相似问题