网站首页 > 基础教程 正文
默认已完成爬虫文档《爬虫学习文档顺序》
并简单搭建完展示页面和管理后台的练习部分
例如
管理后台:
展示页面:
接下来完成Cookie的实现
思路如下图:
创建一个js文件和index.jsp文件
jsp文件内容,都是默认实现,主要是为了引入analytics.js
编写analytics.js文件,函数初始结构
添加一个CookieUtil工具
获取cookie的函数
设置cookie的函数
后续部分
再创建一个tracker,添加一个日志打印函数,方便我们调试
添加变量keys
创建会话建立函数
调用
启动测试下(ctrl+f5强制刷新js,否则可能缓存看不到)
继续编写js
创建generateId产生UUID
添加sid、uuid的get/set方法,类似于java中的部分
添加一个更新方法的函数
创建会话函数
开始会话
查看效果
查看cookie
继续完成js
增加一个配置变量clientConfig
判断拜访时间是否过期
添加到开始会话里
查看效果(更改下过期时间测试)
查看
10s以后
猜你喜欢
- 2024-11-26 工作中,前端开发要看项目,怎么查看别人的js项目代码
- 2024-11-26 Cookie 在爬虫中的应用
- 2024-11-26 55个JS代码让你轻松当大神
- 2024-11-26 操作cookie
- 2024-11-26 9个原生js库助力前端开发,你都用过吗?
- 2024-11-26 Selenium4+Python3系列(七) Iframe、常见控件、JS、Cookie操作
- 2024-11-26 浅谈JavaScript的用处
- 2024-11-26 Web安全:XSS怎么实现?Cookie 劫持如此简单,你的网站安全吗?
- 2024-11-26 Cookies和Session的区别和理解
- 2024-11-26 cookie是什么?有什么用?cookie详解,一篇文章彻底搞懂cookie
- 06-09Socioeconomic growth goals high on meetings' agenda
- 06-09Cities Along Middle Reaches of Yangtze River Agree on 63 Cooperation Items
- 06-09Scientists to make flag flutter on moon
- 06-09CBN丨Foreign-funded institutions bullish on Chinese assets
- 06-09Full Text: Joint Statement between the People's Republic of China and the French Republic on Climate Change on the occasion of the Tenth Anniversary of the Paris Agreement
- 06-092022年底总结,温暖和激励自己的文案
- 06-09百度实时推送代码解决方案(百度实时推送工具)
- 06-09PHP漏洞之跨网站请求伪造(php跨站脚本攻击)
- 最近发表
-
- Socioeconomic growth goals high on meetings' agenda
- Cities Along Middle Reaches of Yangtze River Agree on 63 Cooperation Items
- Scientists to make flag flutter on moon
- CBN丨Foreign-funded institutions bullish on Chinese assets
- Full Text: Joint Statement between the People's Republic of China and the French Republic on Climate Change on the occasion of the Tenth Anniversary of the Paris Agreement
- 2022年底总结,温暖和激励自己的文案
- 百度实时推送代码解决方案(百度实时推送工具)
- PHP漏洞之跨网站请求伪造(php跨站脚本攻击)
- ThinkPHP后台入口地址查找(thinkphp build.php)
- PHP新手如何提高代码质量(php新手如何提高代码质量的方法)
- 标签列表
-
- jsp (69)
- gitpush (78)
- gitreset (66)
- python字典 (67)
- dockercp (63)
- gitclone命令 (63)
- dockersave (62)
- linux命令大全 (65)
- pythonif (86)
- location.href (69)
- dockerexec (65)
- tail-f (79)
- queryselectorall (63)
- location.search (79)
- bootstrap教程 (74)
- deletesql (62)
- linuxgzip (68)
- 字符串连接 (73)
- html标签 (69)
- c++初始化列表 (64)
- mysqlinnodbmyisam区别 (63)
- arraylistadd (66)
- mysqldatesub函数 (63)
- window10java环境变量设置 (66)
- c++虚函数和纯虚函数的区别 (66)