假设我有一个文本
<span class="hide">for real</span><h2 id='show'>Obama is rocking the house</h2>
<span class="hide">not real</span><h2 id='show'>Bill gates is buying stackoverflow</h2>
Run Code Online (Sandbox Code Playgroud)
我需要爬虫来读取
<h2 id='show'>Obama is rocking the house</h2>
<h2 id='show'>Bill gates is buying stackoverflow</h2>
Run Code Online (Sandbox Code Playgroud)
我们能做到吗?
我在这里有点困惑说谷歌读取了一个隐藏的div
但是当我用谷歌搜索一秒钟时,我发现谷歌没有读取隐藏的 div。那么哪个是对的?
http://www.seroundtable.com/archives/002971.html
我的想法是像使用 css 一样使用它。
仅供参考,向用户提供与搜索引擎不同的内容违反了 Google 的服务条款,如果您被抓住,您将被禁止。隐藏但可以通过某种触发器访问的内容(将导航菜单链接悬停在上面,单击图标以展开内容区域等)是可以接受的。但是在您的示例中,您向搜索引擎展示了不同的内容,特别是为了他们的利益,这绝对是您不想做的。