简单的写了一个饿了么满减的爬虫

2018-05-16 10:48:36 +08:00
 m939594960

代码很烂.流水账,但是应该可以凑合用.

https://gist.github.com/hooklife/b416c326e1ea726b38003f44b9109ed0

使用方法,电脑端打开饿了么,选好地址后,

https://www.ele.me/place/{geohash}?latitude={latitude}&longitude={longitude} 获取 url 中 geohash,latitude,longitude 并修改程序中变量

登录账号后获取 cookies 中的 SID,USERID,ubt_ssid 并替换程序中对应位置(大概 24 行)

修改数据库链接账号密码

然后即可运行

mysql 创建表语句

CREATE TABLE `activities` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `tips` varchar(255) DEFAULT NULL,
  `buy` int(5) unsigned DEFAULT '0',
  `discount` double(5,1) DEFAULT '0.0',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;

几个查优惠的语句

# 查询可以用 35-6 红包的最合适的店家
select *,(buy-discount)/buy as q,(buy-discount-6) as b from activities where buy >=35 order by b asc 
# 查询全减的商家
select * from activities where discount=buy order by buy desc 
5180 次点击
所在节点    分享创造
6 条回复
kevindu
2018-05-16 11:42:06 +08:00
嗯 很烂
vtwoextb
2018-05-16 14:26:21 +08:00
嗯 很烂
codelover2016
2018-05-16 16:34:22 +08:00
那个...
确实是很一般.
m939594960
2018-05-16 16:38:59 +08:00
@kevindu
@vtwoextb
@codelover2016
哈哈...能用就行了,要啥自行车.....
oneyian
2018-05-17 08:58:54 +08:00
不挺好的吗。但是进不去了
m939594960
2018-05-17 09:09:56 +08:00
@oneyian 什么进不去了?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/455210

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX