V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
tntin
V2EX  ›  问与答

客户端渲染 + flask 的方式 seo 问题求助

  •  
  •   tntin · 2023-04-11 19:20:50 +08:00 · 380 次点击
    这是一个创建于 436 天前的主题,其中的信息可能已经有所发展或是发生改变。

    前后端分离项目的 seo 目前已经有很多成熟解决方案了,

    大多数 seo 效果好的方案都采用了服务端渲染的方式,并且也是现在的一个趋势。

    目前我们项目有点剑走偏锋 用了比较奇葩的方式:

    使用 nginx 判断 ua

    正常用户指向 vue 前端项目 走正常的客户端渲染流程;

    爬虫访问 被反带到前端服务器的 flask 应用,访问的是服务端渲染的 html 。

    https://imgur.com/2YpgWpH

    nginx 配置大致如下

    map $http_user_agent $backend_server { ~*Baidu 127.0.0.1:5000; ~*Baiduspider 127.0.0.1:5000; ~*Baiduspider-render 127.0.0.1:5000; ~*360Spider 127.0.0.1:5000; ~*bingbot 127.0.0.1:5000; ~*Googlebot 127.0.0.1:5000; ~*Sogou\ web\ spider 127.0.0.1:5000; ~*spider 127.0.0.1:5000; default ""; }

    server { listen 80; server_name www.com; index.html index.htm; root /www/wwwroot/www.com;

    location / {
      if ($backend_server != "") {
      proxy_pass http://$backend_server;
      break;
      }
    index  index.html index.htm;
    try_files $uri $uri/ /index.html;
    }    
    

    }

    现在的问题是,经过一段时间的提交,谷歌和 bing 以及搜狗等 搜索引擎都正常收录了,唯独百度一点动静没有。 看到百度平台也显示抓取量,但是就没有收录。

    是我才用的这种方案本身就有问题呢? 还是百度那边有问题? 还是我的配置有问题?

    tntin
        1
    tntin  
    OP
       2023-04-18 09:25:01 +08:00
    解决了,看来对待百度还是要主动一点,需要经常通过接口提交 url
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3119 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 11:41 · PVG 19:41 · LAX 04:41 · JFK 07:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.