前后端分离项目做爬虫收录,提供蜘蛛爬行最简单方案,创建sitemap xml

2024年5月13日11:36:01

现在很多项目是vue react angular开发的,但是百度爬虫对这样的项目支持不好,很多时候回去采用一些 服务器端渲染(SSR)静态站点生成(SSG) ,当然有些框架支持ssr和ssg效果不好,还有些想不不破坏项目自身的提前下的方案呢?

参考:https://blog.csdn.net/andy_68147772/article/details/135118183

很多年前接手一个angularjs的项目,但是要搞爬虫收录,搞了好久那个时候ssr支持的不太好,所以想了另一个方法。

爬虫是会先爬取 http://127.0.0.1/robots.txt 去读取爬虫规则的,这里面是可以指定stemap xml地址的
例如:

User-agent: *
Allow: /
Sitemap: https://www.xxx.cn/express.xml
Sitemap: https://www.xxx.cn/lastest.xml
Sitemap: https://www.xxx.cn/sitemap1.xml
Sitemap: https://www.xxx.cn/sitemap2.xml
Sitemap: https://www.xxx.cn/sitemap3.xml
Sitemap: https://www.xxx.cn/sitemap4.xml

sitemap规范
https://www.sitemaps.org/protocol.html#index

如果有sitemap的地址,爬虫就会去读取sitemap

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>https://www.xxx.com/page1</loc>
      <lastmod>2023-01-01</lastmod>
      <changefreq>daily</changefreq>
      <priority>0.8</priority>
   </url>
   <url>
      <loc>https://www.xxx.com/page2</loc>
      <lastmod>2023-01-02</lastmod>
      <changefreq>weekly</changefreq>
      <priority>0.6</priority>
   </url>
   <!-- more URLs... -->
</urlset>

那么就可以直接在get的页面的内容接口直接放在地图,让蜘蛛直接获取接口返回的json内容,就不需要渲染,达到让不使用ssr,ssg来让爬虫爬取内容的方法。

laravel支持的sitemap生成工具

composer require spatie/laravel-sitemap

如果内容过多,建议分拆xml文件 Sitemap: https://www.xxx.cn/sitemap4.xml 文件,不然一次太大影响爬虫获取接口返回的时候,注意http头时json格式。

会去求证一下百度蜘蛛爬虫是否可行,我们当年是可以的,因为爬虫技术一直在变,最好找官方支持一下。

在这个项目中,使用了Spring Boot和Vue进行前后端分离的实战。项目包括了多个部分,如前端设计、后端与数据库连接、前后端连接、用户管理功能实现等。\[1\]通过这个项目,你可以学习到一些知识,包括但不限于Spring Boot、MyBatis、MySQL等后端知识,前后端的增删改查交互流程,前端如何请求后端接口和三方接口,前端请求拦截器的实现,前端组件的封装和使用,动态权限菜单的实现,爬虫的实现,悬浮球的实现,文件流操作,抽奖效果,滚动字幕效果,Excel导入和导出,前后端分离项目的打包部署等。\[2\]在开发栈方面,使用了Spring Boot、MyBatis和MySQL等技术。\[2\]在项目中还使用了Swagger文档工具,可以通过添加相应的依赖来使用。\[3\] #### 引用[.reference_title] - *1* [SpringBoot + Vue前后端分离项目实战 || 二:Spring Boot后端与数据库连接](https://blog.csdn.net/qq_56039091/article/details/131306802)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [SpringBoot 和 Vue前后端分离在线工具项目实战,源码+超详细讲解](https://blog.csdn.net/weixin_41231928/article/details/126613596)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [【第二季】【SpringBoot+Vue】前后端分离项目实战笔记](https://blog.csdn.net/m0_37613503/article/details/129349710)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值