preface

People in Shanghai, home for a month, thanks to the government and the company from time to time “airdrop”, the staple food is not lacking, but the food is really not enough to eat, so these days also began to join the ding Dong food grab army, but a few days can not get;

Inadvertently opened the ding-dong last night to buy food, found a time period that can be sent, to buy a bag of Hun stew skin (almost all sold out), it reminds me, ding-dong buy dish can send (capacity) is the dynamic change of time, so I want to write a program, monitoring the change, in a distributed resources with spare time remind of me, and then in the manual to place the order, Theoretically it should be possible to buy food;

After another failed attempt to grab food at 6am this morning, I couldn’t help myself and got up to practice this semi-automatic plug-in idea.

Get ding Dong buy food API

I’m an iPhone, so I need to find an appropriate grab tool. I use stream instead of fiddle on my PC. A few things to note:

1, the default installation is unable to capture HTTPS type, need to be configured in the Settings:

If you want to capture HTTPS requests, you need to enable packet capture, install the CA certificate, and set the trust CA in the general – About – certificate trust Settings to view the request content.

2. The interface under the domain name maicai.api.ddxq.mobi cannot be captured in the ding dong maicai App, so the version of the small program needs to be captured.

Then I successfully got this interface, url: ‘https://maicai.api.ddxq.mobi/order/getMultiReserveTime’, the stream provides copies of curl, import it to the postman, validation can be normal to return the result, Then convert the curl format to node Request.

Building a Node Project

Create a git repository, put your code in it, execute it in node, and find that the console is garble. This problem is caused by a header accept-encoding: ‘deflate, deflate, br’, gzip compression causes gibberish, I removed it and checked it again.

Then write a polling function to query the interface regularly and parse the response data. When I find that the time available for delivery is available, I will be prompted and the message will prompt me to use Bark, an open source tool in ios system.

Being pushed

Bark is a developer’s exclusive push tool, free and stable. After downloading Bark application in appleStore, exclusive BarkId will be generated after opening it, as shown in the figure, copy the link. The notification push event can be triggered by get, Post, etc.

Results show

conclusion

I hope I can buy food early through this small program, I’m really too difficult.

Update: Automatic order Api is being tested, please pay attention.

Update: 2 hours after the execution of the program, the first time to grab food.


This article is only personal technology sharing, please do not use for commercial purposes, if there is any infringement, please contact me to delete.

If you feel helpful, please give a STAR! Github program source code

Collection: My Github blog and case source code