--hook, an electricity supplier (bao) app signature data acquisition, welcomed the exchange

First, what is Hook Technology

  Hook Technology also called hook function before the system does not call this function, the program on the first hook to capture the message hook function to get control, then hook functions can be processed either execution behavior process (changing) the function, also can force to deliver the message end. In simple terms, it is to pull out of the program system to execute code fragments become our own.
  To achieve hook function, there are two steps:
  an interface system 1 provided with an internal, by implementing this interface, and then injected into the system (using the specific scenario)
  2. Dynamic Agent (all scenarios)

Second, the technology of step Hook

  Step Hook technology is also divided into two steps
  1. Locate the hook point (Java layer), the hook point the following conditions must be met: the hook method requires the object belongs must be static, because we are reflected by the object to obtain we have obtained is the object of the system, it is not possible new a new object, the object must be created with the system, so the same subject in order to ensure that only static and systems.
  2. The method hook into the system to perform outside (into our own logic)

Three, hook data acquisition

Because the need for compatibility with older versions of the app, so the revision does not affect older versions of data acquisition.

Providing an interface:

1. Home keyword search. (Search for "socks", all pages will appear goods socks, provide an interface, and returns json string)

2. Store details (including all merchandise shop inside the simple information)

3. Product Details (providing an interface and returns json string)

4. Product All comments (to provide an interface and returns json string)

Fourth, the interface collection efficiency

Under normal circumstances, one minute collecting multiple machines, at least up to 200 beats / min. With the hardware conditions, the data ok.

Five, hook ideas

mou bao - app request is divided into two parts: url + header, without landing, several key parameters: sid, rn, appkey, api, etc., because it is the hook, so we do not know the specific algorithms sign, simply parameters json object underlying passing invoke method (certain parameters written agreement is a guarantee request), open a post-deployment own interface to access it. Machine pressure tolerance decide collection efficiency.

Sixth, combat

Stable, much more stable than web end (eat a lot of losses), there is a small problem at the session failure, is not resolved, please share the discussion. I reply to the comments section. Thank you.

Guess you like

Origin www.cnblogs.com/luruihua/p/11614915.html