90后逝去的青春用代码致敬......
回忆的是情怀,小编专线15504268906回不去的是青春。
01
零食杀




02
玩具杀




03
动画杀





04
游戏杀



看到QQ游戏,让小编想起前段时间腾讯宣布停止乐斗Ⅱ和QQ宠物的运营。。。
可能很多90后都玩过乐斗Ⅱ。但是很遗憾,今天的主角不是它,而是它的兄弟——“Q宠大乐斗”。今天分享的是:如何使用selenium让“Q宠大乐斗”自动运行,自动打游戏。

代码书写小编专线15504268906
因为这个游戏的任务有点多,所以分模块来写比较好,这样逻辑清晰,代码的可读性也更强。
登录小编专线15504268906模块

通过上图可以找出登录的元素位置,直接使用selenium进行登录操作。

上面代码中的第14行是设置等待。如果 WebDriver没有在 DOM中找到元素,将继续等待,超出设定时间后则抛出找不到元素的异常。


(自动登录。。。)
其他模块
等级不同,任务也就不同。所以这里就放上几个共同的模块。具体的任务看下图:

每日奖励模块

乐斗好友模块

其他的模块就不放代码了,毕竟等级不一样,代码可能没有通用性。而且主要的方法就是定位元素,主要是设置等待时长和注意异常情况的判断处理就可以了。
计划任务小编专线15504268906
设置好时间,因为这个游戏的宠物是靠体力来进行的并且每天只能进行一次任务,所以每天定时打一次就可以了。


最后小编专线15504268906
这个自动打游戏的demo,只是单纯的练习一下selenium操作;当然也顺便回忆一下90后的青春,相信有一部分90后小时候还是会玩过这个游戏的。
可能有人就觉得这游戏有点low(确实有点low),那我只能昧着良心回一句:编女神玩的不是游戏,是情怀,懂不懂。

今天的这主题是带大家回忆青春顺便分享个小技能。举一反三会不会更溜?用在别的游戏上试试吧!回忆的是情怀,回不去的是青春。
关注我们!私信小编!小编专线:15504268906
欢迎加入免费IT学习交流群!获取更多新鲜资讯哦~给你IT学习以帮助!
关注我们!私信小编!小编专线:15504268906
欢迎加入免费IT学习交流群!获取更多新鲜资讯哦~给你IT学习以帮助!