V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
m939594960
V2EX  ›  分享创造

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

  •  
  •   m939594960 · 2018-05-16 10:48:36 +08:00 · 5074 次点击
    这是一个创建于 2162 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    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 
    
    6 条回复    2018-05-17 09:09:56 +08:00
    kevindu
        1
    kevindu  
       2018-05-16 11:42:06 +08:00
    嗯 很烂
    vtwoextb
        2
    vtwoextb  
       2018-05-16 14:26:21 +08:00
    嗯 很烂
    codelover2016
        3
    codelover2016  
       2018-05-16 16:34:22 +08:00
    那个...
    确实是很一般.
    m939594960
        4
    m939594960  
    OP
       2018-05-16 16:38:59 +08:00
    @kevindu
    @vtwoextb
    @codelover2016
    哈哈...能用就行了,要啥自行车.....
    oneyian
        5
    oneyian  
       2018-05-17 08:58:54 +08:00
    不挺好的吗。但是进不去了
    m939594960
        6
    m939594960  
    OP
       2018-05-17 09:09:56 +08:00
    @oneyian 什么进不去了?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   955 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:48 · PVG 05:48 · LAX 14:48 · JFK 17:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.