SEO:动态生成的链接可以被抓取吗?
我有一个包含
标记的页面,其中包含 onclick="" 代码,该代码调用 ajax 请求来获取 json 数据,然后迭代结果以形成链接 (
) 附加到页面。这些链接不存在于我网站上的任何其他位置。如何使这些动态生成的链接可抓取?我最初的想法是将
标签转换为带有 href="#" 的
标签,但我对典型爬虫的工作原理了解有限,我认为这不会解决我的问题,因为“#”将是爬虫识别的内容,而不一定是动态生成的输出。除此之外,我根本不想改变滚动定位,这也排除了为
标记提供 id 并让它引用自身的情况。除了创建一个包含我需要抓取的所有链接的新页面之外,我还有其他选择吗?谢谢。
I have a page containing <div>
tags with onclick="" code that calls an ajax request to get json data, and then iterates through the results to form links (<a />
) to append to the page. These links do not exist in any other place on my website. How can I make these dynamically generated links crawlable?
My initial thought was to turn the <div>
tags into <a>
tags with a href="#", but with my limited knowledge of how typical crawlers work, i don't think this would solve my problem since the "#" would be what's recognized by the crawler, and not necessarily the dynamically generated output. This is besides the point that i don't want the scroll positioning to be altered at all, which would also rule out giving the <a>
tag an id and having it reference itself.
Do I have any options aside from making a new page containing all of the links i need to be crawled? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为一般规则,通过 JavaScript 创建或提供的内容无法被搜索引擎找到或索引。 Google 确实支持可抓取 Ajax,但将其用作访问内容的唯一方式不利于可访问性。此外,其他搜索引擎无法获取该内容,这也不是一件好事。基本上 可抓取ajax 是一件坏事。
您应该始终使您的内容可用,而不需要 JavaScript 来获取它。然后,您可以通过添加 JavaScript 来改进您的网站,从而更快或更轻松地获取内容。这称为渐进增强,这就是构建优秀网站的方式。
As a general rule, content that is created or made available through JavaScript cannot be found or indexed by search engines. Google does support crawlable Ajax but using it as the only means of accessing your content is bad for accessibility. Also, other search engines can't get to that content which is also not a good thing. Basically crawable ajax is a bad thing.
You should always make your content available without requiring JavaScript to get it. Then you can improve your site by adding JavaScript to make getting the content faster or easier. This is called Progressive Enhancement and is how good websites are built.