CN106886465B - Data acquisition method and device - Google Patents

Data acquisition method and device Download PDF

Info

Publication number
CN106886465B
CN106886465B CN201510944900.6A CN201510944900A CN106886465B CN 106886465 B CN106886465 B CN 106886465B CN 201510944900 A CN201510944900 A CN 201510944900A CN 106886465 B CN106886465 B CN 106886465B
Authority
CN
China
Prior art keywords
mode
data acquisition
determining
data
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510944900.6A
Other languages
Chinese (zh)
Other versions
CN106886465A (en
Inventor
王凡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Cainiao Smart Logistics Holding Ltd
Original Assignee
Cainiao Smart Logistics Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Cainiao Smart Logistics Holding Ltd filed Critical Cainiao Smart Logistics Holding Ltd
Priority to CN201510944900.6A priority Critical patent/CN106886465B/en
Publication of CN106886465A publication Critical patent/CN106886465A/en
Application granted granted Critical
Publication of CN106886465B publication Critical patent/CN106886465B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The application discloses a data acquisition method, which is used for solving the problem that the data acquisition efficiency of a front end is low in the joint debugging process due to the fact that the requirements for data acquisition modes are inconsistent. The method comprises the following steps: the front end receives a data acquisition instruction; responding to the instruction, and determining preset mode information; determining a data acquisition mode mapped by the preset mode information according to a preset mapping relation between the mode information and the corresponding data acquisition mode; and acquiring the data by adopting the determined data acquisition mode. The application also discloses a data acquisition device.

Description

Data acquisition method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data acquisition method and apparatus.
Background
Software development can be divided into front-end development and back-end development.
The front end refers to a functional module for implementing the front end function. The front-end function may specifically include, but is not limited to, at least one of a structural implementation of the interface, an appearance visual representation of the interface, and an interactive implementation at the interface level. Front-end development mainly refers to the development of front-end developers.
The back end refers to a functional module for realizing back end functions. The backend function may specifically include, but is not limited to, some function implementations of the interface, for example, a service processing logic implementation triggered by the interface belongs to the backend function. The back-end development mainly refers to the development of back-end developers.
At present, in the software development process, front-end and back-end developers may need to perform front-end and back-end joint debugging according to actual requirements. When joint debugging is performed, data interaction may occur in order to realize certain functions of the front end, and the front end can acquire data required for realizing the functions of the front end by performing the data interaction.
In actual development, due to the inconsistency of the requirements of the front end and the back end for the data acquisition mode, for example, the implementation logic of the data acquisition mode written into the JS code of the front end may not match the data acquisition mode expected to be adopted by the back end. At this time, in order to ensure smooth acquisition of data, the front-end personnel needs to modify the implementation logic of the data acquisition mode in the JS code.
However, the adoption of the mode of modifying the implementation logic of the data acquisition mode in the JS code has the problem of low efficiency, and further reduces the data acquisition efficiency of the front end in the joint debugging process.
Disclosure of Invention
The embodiment of the application provides a data acquisition method, which is used for solving the problem that the data acquisition efficiency of a front end in a joint debugging process is possibly low due to inconsistent requirements on data acquisition modes.
The embodiment of the application further provides a data acquisition device, which is used for solving the problem that the data acquisition efficiency of the front end is low in the joint debugging process due to the fact that the requirements for the data acquisition modes are inconsistent.
The embodiment of the application adopts the following technical scheme:
a method of data acquisition, comprising:
the front end receives a data acquisition instruction;
responding to the instruction, and determining preset mode information;
determining a data acquisition mode mapped by the preset mode information according to a preset mapping relation between the mode information and the corresponding data acquisition mode;
and acquiring the data by adopting the determined data acquisition mode.
A data acquisition device is applied to a front end and comprises:
an instruction receiving unit for receiving a data acquisition instruction;
an information determination unit configured to determine preset mode information in response to the instruction received by the instruction receiving unit;
the mode determining unit is used for determining the data acquisition mode mapped by the mode information determined by the information determining unit according to the preset mapping relation between the mode information and the corresponding data acquisition mode;
and the data acquisition unit is used for acquiring data by adopting the data acquisition mode determined by the mode determination unit.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects:
the data acquisition mode can be represented by presetting the mode information, so that even if the requirements of front-end developers and rear-end developers for the data acquisition mode are inconsistent, the mode information can be simply modified to achieve the purpose of changing the data acquisition mode, and the front-end developers do not need to modify the implementation logic of the data acquisition mode in the JS codes. Therefore, compared with the prior art, the data acquisition efficiency of the front end in the joint debugging process can be improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic flow chart illustrating an implementation of a data acquisition method according to an embodiment of the present application;
FIG. 2a is a schematic diagram of adding an "adaptation layer" to data acquisition logic in a VM-based manner;
fig. 2b is a schematic application flow diagram of a data acquisition method provided in the embodiment of the present application in practice;
fig. 2c is a logic diagram implemented by the adaptation layer in the embodiment of the present application when the BUI control displays data acquired by the front end in a "display by Select" manner;
fig. 2d is a logic diagram implemented by the adaptation layer in the embodiment of the present application when the BUI control displays the data acquired by the front end in a manner of "displaying by using the Menu bar Menu";
fig. 2e is a logic diagram implemented by the adaptation layer in the embodiment of the present application when the way in which the BUI control displays the data acquired by the front end is "display using Table";
fig. 3 is a schematic flow chart of another practical application of the data acquisition method according to the embodiment of the present application;
fig. 4 is a schematic structural diagram of a data acquisition device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Example 1
In order to solve the problem that the data acquisition efficiency of a front end is low in a joint debugging process due to inconsistent requirements for data acquisition modes, embodiment 1 of the present application provides a data acquisition method. The specific implementation flow chart of the method is shown in fig. 1, and comprises the following steps:
step 11, the front end receives a data acquisition instruction;
the front end refers to a functional module for implementing a front end function. The front-end function may specifically include, but is not limited to, at least one of a structural implementation of the interface, an appearance visual representation of the interface, and an interactive implementation at the interface level. For example, a web page that a user can see through a PC interface is one of front ends, and when the user browses a web page, the user clicks information on the web page, such as data of characters, pictures, and the like, a data acquisition instruction may be triggered.
In the front-end and back-end joint debugging process, the front-end developer may also receive the data acquisition instruction through other manners, such as a manner of inputting a code for triggering the data acquisition instruction to the front-end.
Step 12, responding to the data acquisition instruction received in the step 11, and determining preset mode information;
specifically, in response to the data acquisition instruction, the front end often calls and executes a JS file in the source file of the interface (e.g., web page). The source file referred to herein is composed of the source code of the interface, and the source file generally includes a JS file composed of JS codes.
In the embodiment of the present application, the preset mode information may be determined in, but not limited to, two modes. Wherein, the first mode can include: the front end responds to the data acquisition instruction, and searches a specified field (which can be referred to as a first specified field for distinguishing from other fields described later) in the JS file called by the data acquisition instruction; and the front end determines preset mode information according to the search result.
For example, if the search result is that the first designated field is found, determining that the first designated field is not in an empty state as the preset mode information; and if the search result is that the first designated field is not searched, determining the state that the first designated field is empty as the preset mode information.
The data acquisition modes related in the embodiments of the present application include, but are not limited to, the following two types:
1. based on Remote Procedure Call Protocol (RPC).
The realization principle of the mode is as follows: the front-end obtains data fed back by the back-end according to the RPC request by sending the RPC request to the back-end.
For example, the front end may use the AJAX (Asynchronous JavaScript And XML, AJAX) technology to send an RPC request for obtaining data to the back end, so as to obtain data fed back by the back end according to the RPC request.
2. A Velocity template (VM) based approach.
The realization principle of the mode is as follows: the front end directly accesses the java object through a template engine of the VM and a corresponding template language, so that data written into the java object is obtained.
Currently, in front-end development, JavaScript (JS) is an transliterated scripting language, which is widely used in front-end development and can be used to add interactive behaviors to a front-end page. In some related technologies, a front-end developer may compile implementation logic of one of the data acquisition manners into a JS code and set the JS code in a JS file of the front end, so that the front end may implement data acquisition by using the corresponding data acquisition manner by operating the JS code.
In the embodiment of the application, after learning that the data acquisition mode that the back-end developer expects the front end to adopt, the front-end developer can set (if set to be empty or not empty) the first specified field in the JS file to be called by the data acquisition instruction, so as to achieve the purpose of setting the mode information in advance. Specifically, when a back-end developer expects that the data acquisition mode adopted by the front-end is a call mode based on RPC, the first designated field may be set to null; when the data acquisition mode adopted by the front end is expected to be a VM-based mode by the developer, the first designated field can be set to be not null. Or, when the back-end developer expects the data acquisition mode adopted by the front-end to be a call mode based on RPC, the first designated field may be set to be not null; and when the developer expects that the data acquisition mode adopted by the front end is a VM-based mode, the first designated field can be set to be null. The specific setting manner of the first designated field may be determined according to actual circumstances, and is not limited in the embodiment of the present application.
The first specific field described in the embodiment of the present application may be, for example, a queryUri field.
The second mode is further described below.
The second mode may include: the front end responds to the data acquisition instruction and determines a set switch state; and determining preset mode information according to the determination result.
Specifically, when the determination result is that the switch is in the on state, the switch is in the on state and is determined as the preset mode information; and when the switch is in the closed state as a result of the determination, determining the switch in the closed state as the preset mode information.
In the embodiment of the application, a certain configuration item of a certain JS file can be used as the switch, and a front-end developer sets the value of the configuration item, so that the purpose of setting mode information in advance is achieved. For example, if the value of the configuration item is set to 0, it indicates that the switch is in an on state; if the value is set to 1, it indicates that the switch is in the off state. Specifically, the front-end developer may set the value of the configuration item after knowing a data acquisition manner that the back-end developer expects the front end to adopt. For example, when a back-end developer expects that the data acquisition mode adopted by the front-end is a call mode based on RPC, the value of the configuration item may be set to 0; and when the developer expects the data acquisition mode adopted by the front end to be a VM-based mode, the value of the configuration item can be set to 1. Or, when the back-end developer expects the data acquisition mode adopted by the front-end to be a call mode based on RPC, the value of the configuration item may be set to 1; and when the developer expects the data acquisition mode adopted by the front end to be a VM-based mode, the value of the configuration item can be set to 0. The specific setting manner of the first designated field may be determined according to actual circumstances, and is not limited in the embodiment of the present application.
Step 13, determining a data acquisition mode mapped by the preset mode information according to a preset mapping relation between the mode information and the corresponding data acquisition mode;
for example, continuing with the above example of the first manner and the second manner, the preset mapping relationship between the different manner information and the corresponding data acquisition manner may be shown in the following table. Table 1 is a mapping relationship corresponding to the first method, and table 2 is a mapping relationship corresponding to the second method.
Table 1:
preset mode information Data acquisition mode
State where the first designated field is not empty RPC-based calling mode
State with first specified field empty VM-based approach
Table 2:
preset mode information Data acquisition mode
The switch is in the on state RPC-based calling mode
The switch is in the off state VM-based approach
And step 14, acquiring data by adopting the determined data acquisition mode.
Continuing with the above example using the first manner and the second manner, if the determined data acquisition manner is the RPC-based call manner, data fed back by the back end according to the RPC request may be acquired by sending the RPC request to the back end.
Since the scheme for obtaining data based on the RPC calling method is a relatively mature technology in the prior art, the specific implementation process of the method is not described in detail in the embodiments of the present application.
It should be noted that, if the determined data obtaining manner is a VM-based manner, the java object may be directly accessed through a template engine of the VM and a corresponding template language, so as to obtain data written in the java object.
In this embodiment of the application, in order to enable the user to intuitively know that step 14 is executed, after step 14 is executed, the method may further include the steps of: and displaying the acquired data.
Specifically, In the embodiment of the present application, an embedded User Interface (BUI) control may be adopted to display the acquired data.
It should be noted that, when data is acquired by using the RPC calling method, since information of a data display method (for example, a pull-down box, a menu bar, a table, or the like, which can be implemented by the BUI) can be carried in the transmitted RPC request, data fed back by the back end and having a format matched with the data display method can be acquired, and thus the data acquired by using the method can be directly displayed by the BUI control.
For the VM-based mode, if the VM-based mode provided in the prior art is adopted, the format of the data obtained by the VM-based mode often does not support direct display by the BUI control, but supports display by a relatively native mode.
In the embodiment of the application, the data display is more visual and attractive in view of the fact that the data display mode is realized by the BUI control, and therefore the data obtaining process based on the VM mode can be realized by adopting the following substeps, so that the obtained data can support direct display by the BUI control.
And (3) substep I: the front end searches for a specified field in the VM (hereinafter, the specified field is referred to as a second specified field), and if the specified field is found, the substep II is executed; otherwise, executing substep III;
and a substep II: acquiring data in a second specified field;
it should be noted that, if the second specified field can be found, the data included in the second specified field is the data corresponding to the data acquisition instruction received by the front end. The data may be pre-set in the second designated field by a back-end developer. Specifically, when the back-end developer sets data in the second specified field, the back-end developer may set the data that supports direct display by the BUI control, so that the data in the second specified field, which is acquired by the front-end in a VM-based manner, may be directly displayed by the BUI control.
In this embodiment of the application, the second specified field may refer to an attribute value of a specified field (the name of the field may be data-item, for example) in a drop-down box (Select) element in the VM, an attribute value of a specified field (the name of the field may be data, for example) in a Menu bar (Menu) object, and an attribute value of a specified field (the name of the field may be date-item, for example) in a Table (Table) element.
The various second designated fields described above are fields relating to a predetermined data presentation manner. Therefore, in this embodiment of the present application, the front end searching for the second specified field in the VM may specifically include:
the front end determines the identification of the second specified field according to a preset data display mode;
in the VM, a second specified field corresponding to the identification of the second specified field is looked up.
Specifically, when the data presentation manner is "present with Select", the identifier of the second specified field is the identifier of the specified field in the Select element. The front end thereby obtains data in the second specified field, including: the front end obtains the attribute value of the specified field in the Select element.
Similarly, when the data presentation mode is "presentation with Menu bar Menu", the identification of the second specified field is the identification of the specified field in the Menu object. The front end thereby obtains data in the second specified field, including: the attribute values of the specified fields in the Menu object are obtained.
Similarly, when the data presentation mode is "presentation with Table" the identifier of the second specified field is the identifier of the specified field in the Table object. The front end obtains data in a second specified field, including: and acquiring the attribute value of the specified field in the Table object.
Substep III: data of a hypertext Markup Language (HTML) element is crawled.
In the embodiment of the present application, the fetching of the data of the HTML element may be specifically implemented by a Document Object Model (DOM), for example. Generally, to change some content of an HTML page, it is necessary to obtain access to all elements (i.e., HTML elements) in the HTML page. This entry, along with the methods and properties of adding, moving, changing, or removing HTML elements, is obtained through the DOM. Since obtaining data of an HTML element through DOM is a relatively mature prior art, the embodiments of the present application are not described in detail. In the embodiment of the application, the data of the HTML element acquired through the DOM can be generally and directly displayed by the BUI control.
By adopting the method provided by the embodiment of the application, which data acquisition mode should be adopted can be represented by presetting the mode information, so that even if the requirements of the front-end developer and the rear-end developer on the data acquisition modes are inconsistent, the purpose of changing the data acquisition modes can be achieved simply by modifying the mode information, and the front-end developer does not need to modify the implementation logic of the data acquisition modes in the JS codes. Therefore, compared with the prior art, the data acquisition efficiency of the front end in the joint debugging process can be improved.
Example 2
In embodiment 2, an application flow of the data acquisition method provided in embodiment 1 of the present application in practice is mainly described.
In embodiment 2, in consideration of displaying data acquired by a front end by using a BUI control, a user may intuitively know specific content of the acquired data, so that an "adaptation layer" as shown in fig. 2a is added to a data acquisition logic based on a VM manner. The function of the 'adaptation layer' is mainly to enable data obtained by the front end based on a VM mode to directly support display by adopting a BUI control.
The steps included in the application flow provided in embodiment 2 are described in detail below with reference to fig. 2 b.
Step 21, the front end receives a data acquisition instruction;
step 22, the front end responds to the instruction, searches a queryUri field in the JS code called by the instruction, and judges whether the queryUri field is empty, if not, step 23 is executed, and if the queryUri field is empty, step 24 is executed;
wherein, the queryUri field is used for representing an asynchronous request address. If the field is empty, it indicates that there is no asynchronous request address, that is, the adopted data acquisition mode is not a call mode based on RPC, but a mode based on VM; otherwise, the data acquisition mode adopted is the RPC-based calling mode.
Step 23, the front end sends an RPC request for requesting to acquire data to the back end, and after successfully receiving data fed back by the back end in response to the RPC request, the flow is ended;
step 24, the front end determines a mode to be adopted for showing the acquired data (the mode can be determined according to the adopted BUI control), determines a second specified field according to the mode, and further determines whether the second specified field can be found in the VM; if the search result is found, executing the step 25, otherwise, executing the step 26;
step 25, the front end acquires the data in the second specified field, and displays the acquired data by using the BUI control, and the process is ended;
it should be noted that, when the BUI control displays the acquired data in a "display by using Select", the second specified field is a specified field in the Select element. The front end thereby obtains data in the second specified field, including: the front end obtains the attribute value of the specified field in the Select element.
Similarly, when the manner is "show with Menu bar Menu", the identification of the second specified field is the identification of the specified field in the Menu object. The front end thereby obtains data in the second specified field, including: the attribute values of the specified fields in the Menu object are obtained.
Similarly, when the manner is "show with Table" the identifier of the second specified field is the identifier of the specified field in the Table object. The front end obtains data in a second specified field, including: and acquiring the attribute value of the specified field in the Table object.
And 26, acquiring data of the HTML element through the DOM, displaying the acquired data by using the BUI control, and ending the process.
It should be noted that steps 22 to 26 may be logic implemented by the adaptation layer shown in fig. 2 a. Specifically, when the BUI control displays the data acquired by the front end in a "display by Select", the logic implemented by the adaptation layer is as shown in fig. 2 c.
Similarly, when the BUI control presents the data obtained by the front end in a manner of "presenting with Menu bar Menu", the logic implemented by the adaptation layer is as shown in fig. 2 d.
Similarly, when the BUI control displays the data acquired by the front end in a "display with Table", the logic implemented by the adaptation layer is as shown in fig. 2 e.
By encapsulating the logic contained in the above-described flow described in example 2, a uniform method for retrieving data (which may be named getData, for example) is obtained. Based on the method, a front-end developer does not need to care what data acquisition mode is adopted by the front end, and can directly acquire and display data by calling the method, so that the code change cost caused by inconsistent requirements of the front-end developer and a rear-end developer on the data acquisition mode in joint debugging is avoided.
Example 3
In embodiment 3, another practical application flow of the data acquisition method provided in embodiment 1 of the present application is mainly described.
The steps included in the application flow provided in embodiment 3 are described in detail below with reference to fig. 3.
Step 31, the front end receives a data acquisition instruction;
step 32, the front end responds to the data acquisition instruction and calls the packaged RPC component;
it should be noted that, in the RPC component, a configuration item for implementing a switch, an implementation logic of a call mode based on RPC, and a rendering logic required for displaying the acquired data are packaged.
Step 33, the front end judges whether the value of the configuration item encapsulated in the component and used for realizing the switch is 1; if the value is 1, determining that the switch is in an open state, and executing step 34; otherwise, determining that the switch is in a closed state, and executing step 35;
step 34, the front end runs the RPC component-based calling mode implementation logic and the rendering logic, so as to obtain data by sending an RPC request and display the data, and the flow is finished;
and step 35, the front end acquires and displays data in a VM-based mode, and the process is finished.
Through the above flow provided by embodiment 3, the front-end developer only needs to change the value of the configuration item in the component, and can change the data acquisition mode without modifying the implementation logic of the data acquisition mode in the JS code like the prior art, so that the code change cost caused by inconsistent requirements of the front-end developer and the rear-end developer on the data acquisition mode in joint debugging can be avoided.
Example 4
In order to solve the problem that the data acquisition efficiency of the front end in the joint debugging process is low due to inconsistent requirements on data acquisition modes, the present application embodiment 4 provides a data acquisition device based on the same inventive concept as that in embodiments 3 to 3. The device can be a front end, and also can be a functional module contained in the front end.
Specifically, the schematic structural diagram of the apparatus is shown in fig. 4, and includes the following functional units:
an instruction receiving unit 41 for receiving a data acquisition instruction;
an information determining unit 42 for determining preset mode information in response to the data acquisition instruction received by the instruction receiving unit 41;
a mode determining unit 43, configured to determine, according to a preset mapping relationship (hereinafter referred to as the mapping relationship) between the mode information and the corresponding data obtaining mode, a data obtaining mode to which the mode information determined by the information determining unit 42 is mapped;
a data obtaining unit 44, configured to obtain data by using the data obtaining mode determined by the mode determining unit 43.
In an embodiment, if the data acquisition instruction is an instruction for calling the JS code, the preset mode information may be determined in an adaptation mode. Specifically, the information determining unit 42 may, in response to the data obtaining instruction, find a first specified field in the JS code called by the data obtaining instruction; and determining preset mode information according to the search result.
For example, if the information determining unit 42 finds the first designated field, it determines that the first designated field is not empty as the preset mode information; and if the first designated field is not found, determining the state that the first designated field is empty as the preset mode information.
Alternatively, in one embodiment, the preset mode information may be determined using a switching mode. Specifically, the information determination unit 42 may be configured to determine the state of the set switch in response to the data acquisition instruction; and determining preset mode information according to the determination result.
For example, when determining that the switch is in the on state, the information determining unit 42 determines that the switch is in the on state as the preset mode information; and when the switch is determined to be in the closed state, determining the switch to be in the closed state as the preset mode information.
When the adaptation mode is adopted, the mode determining unit 43 may be configured to determine, according to the mapping relationship, a data obtaining mode mapped by the mode information determined by the information determining unit 42, as a RPC-based calling mode (or a VM-based mode), when the state in which the first specified field is not empty is determined as the preset mode information; when the first designated field is in an empty state and is determined as the preset mode information, according to the mapping relationship, the data acquisition mode mapped by the mode information determined by the information determination unit 42 is determined to be a VM-based mode (or RPC-based calling mode).
When the switch mode is adopted, the mode determining unit 43 may be configured to determine, when the switch is in the on state and is determined to be the preset mode information, that the mapped data obtaining mode is a RPC-based calling mode (or a VM-based mode) according to the mapping relationship; and when the switch is in a closed state and the preset mode information is determined, determining that the mapped data acquisition mode is a VM-based mode (or RPC-based calling mode) according to the mapping relation.
Whether in the adapt mode or the switch mode, the data acquisition unit 44 may be configured to: when the data acquisition mode of the mapping is determined to be a VM-based mode according to the mapping relation, searching a second specified field in a VM template language; if the second specified field is found, acquiring data in the second specified field; and if the second specified field is not found, capturing the data of the HTML element.
Whether in the adapt mode or the switch mode, the data acquisition unit 44 may be configured to: determining the identifier of the second specified field according to a preset data display mode; in the VM, a second specified field corresponding to the identification of the second specified field is looked up.
In an embodiment, the determining, by the data obtaining unit 44, the identifier of the second specified field according to a predetermined data presentation manner may include:
when the data display mode is display by using a drop-down frame Select, acquiring a data-item attribute value of a Select element;
when the data display mode is display by using a Menu bar Menu, acquiring a data value of a Menu object;
and when the data display mode is the display by using the Table, acquiring the data-item attribute value of the Table object.
In one embodiment, the data acquisition unit 44 may be configured to: and if the second specified field is not found, capturing data of DOM elements in the HTML page.
In an implementation manner, in order to facilitate a user to visually check acquired data, the apparatus provided in the embodiment of the present application may further include:
and a presentation unit, configured to present the data acquired by the data acquisition unit 44 by using the BUI component.
By adopting the scheme provided by the embodiment of the application, which data acquisition mode should be adopted can be represented by presetting the mode information, so that even if the requirements of the front-end developer and the rear-end developer on the data acquisition modes are inconsistent, the purpose of changing the data acquisition modes can be achieved simply by modifying the mode information, and the front-end developer does not need to modify the implementation logic of the data acquisition modes in the JS codes. Therefore, compared with the prior art, the data acquisition efficiency of the front end in the joint debugging process can be improved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (24)

1. A method of data acquisition, comprising:
the front end receives a data acquisition instruction;
responding to the instruction, calling and operating a JS file in the interface source file, and determining preset mode information, wherein the mode information is obtained by setting the JS file after a front-end developer knows that a rear-end developer expects a data acquisition mode adopted by a front end;
determining a data acquisition mode mapped by preset mode information according to a preset mapping relation between the mode information and a corresponding data acquisition mode, wherein the data acquisition mode comprises a remote procedure call protocol (RPC) -based calling mode or a Virtual Machine (VM) -based mode;
and acquiring the data by adopting the determined data acquisition mode.
2. The method of claim 1, wherein the data acquisition instruction is an instruction to invoke a JS code; then
Responding to the instruction, and determining preset mode information, wherein the preset mode information comprises the following steps:
the front end responds to the instruction, and a first appointed field in the JS code called by the instruction is searched;
and determining preset mode information according to the search result.
3. The method of claim 2, wherein determining preset mode information according to the search result comprises:
if the first designated field is found, determining the state that the first designated field is not empty as the preset mode information;
and if the first designated field is not found, determining the state that the first designated field is empty as the preset mode information.
4. The method according to claim 3, wherein determining the data acquisition mode to which the preset mode information is mapped according to the mapping relationship comprises:
when the first designated field is not in an empty state and is determined as the preset mode information, determining that the mapped data acquisition mode is a remote procedure call protocol (RPC) based calling mode according to the mapping relation; when the first designated field is in an empty state and is determined as the preset mode information, determining the mapped data acquisition mode to be a VM-based mode according to the mapping relation; or the like, or, alternatively,
when the first designated field is not in an empty state and is determined as the preset mode information, determining the mapped data acquisition mode to be a VM-based mode according to the mapping relation; and when the first designated field is in an empty state and is determined as the preset mode information, determining that the mapped data acquisition mode is a remote procedure call protocol (RPC) based calling mode according to the mapping relation.
5. The method of claim 1, wherein in response to the instruction, invoking and executing a JS file in the interface source file, determining preset mode information, comprises:
the front end responds to the instruction, and determines the state of the set switch based on the value of the configuration item preset in the JS file;
and determining preset mode information according to the determination result.
6. The method of claim 5, wherein determining the preset mode information according to the determination result comprises:
when the switch is determined to be in the on state, determining the switch to be in the on state as the preset mode information;
and when the switch is determined to be in the closed state, determining the switch to be in the closed state as the preset mode information.
7. The method according to claim 6, wherein determining the data obtaining manner to which the preset manner information is mapped according to the mapping relationship comprises:
when the switch is in an on state and the preset mode information is determined, determining that the mapped data acquisition mode is a calling mode based on RPC according to the mapping relation; when the switch is in a closed state and the preset mode information is determined, determining the mapped data acquisition mode to be a VM-based mode according to the mapping relation; or the like, or, alternatively,
when the switch is in an on state and the preset mode information is determined, determining the mapped data acquisition mode to be a VM-based mode according to the mapping relation; and when the switch is in a closed state and the preset mode information is determined, determining that the mapped data acquisition mode is a calling mode based on RPC according to the mapping relation.
8. The method according to any one of claims 1 to 7, wherein when it is determined that the mapped data acquisition mode is a VM-based mode according to the mapping relationship, acquiring data by using the determined data acquisition mode includes:
the front end searches a second specified field in the VM template language;
if the second specified field is found, acquiring data in the second specified field;
and if the second specified field is not found, capturing data of the HTML element.
9. The method of claim 8, wherein the front-end looking up a second specified field in the VM comprises:
the front end determines the identification of the second specified field according to a preset data display mode;
in the VM, a second specified field corresponding to the identification of the second specified field is looked up.
10. The method of claim 9, wherein:
when the data display mode is display by using a drop-down frame, the front end acquires data in a second specified field, and the method comprises the following steps: acquiring an attribute value of a specified field in a Select element;
when the data display mode is display by using the Menu bar Menu, the front end acquires data in a second specified field, and the method comprises the following steps: acquiring an attribute value of a specified field in the Menu object;
when the data display mode is display by using Table, the front end acquires data in a second specified field, including: and acquiring the attribute value of the specified field in the Table object.
11. The method of claim 8, wherein crawling data of hypertext markup language (HTML) elements comprises:
and grabbing the data of the HTML element through a Document Object Model (DOM).
12. The method of any one of claims 1 to 7, further comprising:
and presenting the acquired data by utilizing a user interface BUI component of the browser.
13. A data acquisition apparatus, for use in a front end, the apparatus comprising:
an instruction receiving unit for receiving a data acquisition instruction;
the information determining unit is used for responding to the instruction received by the instruction receiving unit, calling and operating the JS file in the interface source file, and determining preset mode information, wherein the mode information is obtained by setting the JS file after a front-end developer learns that a rear-end developer expects a data acquisition mode adopted by a front end;
the mode determining unit is used for determining the data acquisition mode mapped by the mode information determined by the information determining unit according to the preset mapping relation between the mode information and the corresponding data acquisition mode, wherein the data acquisition mode comprises a remote procedure call protocol (RPC) based calling mode or a Virtual Machine (VM) based mode;
and the data acquisition unit is used for acquiring data by adopting the data acquisition mode determined by the mode determination unit.
14. The apparatus of claim 13, wherein the data acquisition instruction is an instruction to invoke a JS code; then
An information determination unit configured to: responding to the instruction, and searching a first specified field in the JS code called by the instruction; and determining preset mode information according to the search result.
15. The apparatus of claim 14, wherein:
an information determining unit, configured to determine, if the first specified field is found, that the first specified field is not empty as the preset mode information; and if the first designated field is not found, determining the state that the first designated field is empty as the preset mode information.
16. The apparatus of claim 15, wherein the manner determining unit is to:
when the first designated field is not in an empty state and is determined as the preset mode information, determining that the mapped data acquisition mode is a remote procedure call protocol (RPC) based calling mode according to the mapping relation; when the first designated field is in an empty state and is determined as the preset mode information, determining the mapped data acquisition mode to be a VM-based mode according to the mapping relation; or the like, or, alternatively,
when the first designated field is not in an empty state and is determined as the preset mode information, determining the mapped data acquisition mode to be a VM-based mode according to the mapping relation; and when the first designated field is in an empty state and is determined as the preset mode information, determining that the mapped data acquisition mode is a remote procedure call protocol (RPC) based calling mode according to the mapping relation.
17. The apparatus of claim 13, wherein the information determining unit is to:
determining the state of the set switch based on the value of the configuration item preset in the JS file in response to the instruction; and determining preset mode information according to the determination result.
18. The apparatus of claim 17, wherein the information determining unit is to:
when the switch is determined to be in the on state, determining the switch to be in the on state as the preset mode information; and when the switch is determined to be in the closed state, determining the switch to be in the closed state as the preset mode information.
19. The apparatus of claim 18, wherein the manner determining unit is to:
when the switch is in an on state and the preset mode information is determined, determining that the mapped data acquisition mode is a calling mode based on RPC according to the mapping relation; when the switch is in a closed state and the preset mode information is determined, determining the mapped data acquisition mode to be a VM-based mode according to the mapping relation; or the like, or, alternatively,
when the switch is in an on state and the preset mode information is determined, determining the mapped data acquisition mode to be a VM-based mode according to the mapping relation; and when the switch is in a closed state and the preset mode information is determined, determining that the mapped data acquisition mode is a calling mode based on RPC according to the mapping relation.
20. The apparatus of any of claims 13 to 19, wherein the data acquisition unit is configured to:
when the data acquisition mode of the mapping is determined to be a VM-based mode according to the mapping relation, searching a second specified field in a VM template language;
if the second specified field is found, acquiring data in the second specified field;
and if the second specified field is not found, capturing data of the HTML element.
21. The apparatus of claim 20, wherein the data acquisition unit is to:
determining the identifier of the second specified field according to a preset data display mode;
in the VM, a second specified field corresponding to the identification of the second specified field is looked up.
22. The apparatus of claim 21, wherein the data acquisition unit is to:
when the data display mode is display by using a drop-down frame, the front end acquires data in a second specified field, and the method comprises the following steps: acquiring an attribute value of a specified field in a Select element;
when the data display mode is display by using the Menu bar Menu, the front end acquires data in a second specified field, and the method comprises the following steps: acquiring an attribute value of a specified field in the Menu object;
when the data display mode is display by using Table, the front end acquires data in a second specified field, including: and acquiring the attribute value of the specified field in the Table object.
23. The apparatus of claim 20, wherein the data acquisition unit is to:
and if the second specified field is not found, capturing the data of the HTML element through the Document Object Model (DOM).
24. The apparatus of any of claims 13 to 19, further comprising:
and the presentation unit is used for presenting the data acquired by the data acquisition unit by utilizing a user interface BUI component of the browser.
CN201510944900.6A 2015-12-16 2015-12-16 Data acquisition method and device Active CN106886465B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510944900.6A CN106886465B (en) 2015-12-16 2015-12-16 Data acquisition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510944900.6A CN106886465B (en) 2015-12-16 2015-12-16 Data acquisition method and device

Publications (2)

Publication Number Publication Date
CN106886465A CN106886465A (en) 2017-06-23
CN106886465B true CN106886465B (en) 2021-06-15

Family

ID=59176178

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510944900.6A Active CN106886465B (en) 2015-12-16 2015-12-16 Data acquisition method and device

Country Status (1)

Country Link
CN (1) CN106886465B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110889272A (en) * 2019-11-29 2020-03-17 中国银行股份有限公司 Data processing method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102347895A (en) * 2011-06-21 2012-02-08 杭州华三通信技术有限公司 Method and equipment for transmitting monitoring data
CN102938839A (en) * 2012-11-13 2013-02-20 浙江宇视科技有限公司 Monitoring front-end equipment and encoding server
CN103577599A (en) * 2013-11-15 2014-02-12 北京邮电大学 Method and device for storing local data through mobile terminal

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101193125B (en) * 2006-11-20 2012-07-04 华为技术有限公司 A method and device for local device configuration management of user
US9116855B2 (en) * 2010-06-17 2015-08-25 Nec Corporation Data processing system and data processing method
CN104579695B (en) * 2013-10-23 2018-07-20 新华三技术有限公司 A kind of data forwarding device and method
CN105138312B (en) * 2014-06-05 2018-07-03 阿里巴巴集团控股有限公司 A kind of table generation method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102347895A (en) * 2011-06-21 2012-02-08 杭州华三通信技术有限公司 Method and equipment for transmitting monitoring data
CN102938839A (en) * 2012-11-13 2013-02-20 浙江宇视科技有限公司 Monitoring front-end equipment and encoding server
CN103577599A (en) * 2013-11-15 2014-02-12 北京邮电大学 Method and device for storing local data through mobile terminal

Also Published As

Publication number Publication date
CN106886465A (en) 2017-06-23

Similar Documents

Publication Publication Date Title
CN105354013B (en) Application interface rendering method and device
CN105354014B (en) Application interface renders methods of exhibiting and device
US20220318336A1 (en) Method and Terminal Device for Extracting Web Page Content
KR102105261B1 (en) Method and device for displaying interface data
EP2352101A1 (en) Data processing device and processing method of web page
CN105868096B (en) For showing the method, device and equipment of web page test result in a browser
CN109558323B (en) System, method and apparatus for debugging pages
CN110851756A (en) Page loading method and device, computer readable storage medium and terminal equipment
CN105160028B (en) Web page browsing implementation method and browser realize system
CN109740092B (en) Browser system, message processing method, electronic device, and storage medium
CN106407388A (en) A web page generating method and apparatus
CN105549972A (en) Unified authentication protocol-based mvc frame structure and running method thereof
CN102981848A (en) Webpage main body element processing browser and method
CN110781425B (en) Display method, device and equipment of mobile terminal H5 page and storage medium
CN112835809A (en) Test data setting method, device, equipment and medium based on browser
CN108319474B (en) Page information generation method, device and equipment
CN110851123A (en) WebGIS power grid visualization framework construction method, system and device based on SpringMVC
CN113971257A (en) Function menu access method and device for hybrid application
WO2019000894A1 (en) Method and device for generating article outline
US20160103815A1 (en) Generating mobile web browser views for applications
CN107391175B (en) Control data configuration method and computer readable storage medium
CN106886465B (en) Data acquisition method and device
CN112287255B (en) Page construction method and device, computing equipment and computer readable storage medium
CN109240664A (en) A kind of method and terminal acquiring user behavior information
CN111881043B (en) Page testing method and device, storage medium and processor

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20180321

Address after: Four story 847 mailbox of the capital mansion of Cayman Islands, Cayman Islands, Cayman

Applicant after: CAINIAO SMART LOGISTICS HOLDING Ltd.

Address before: Cayman Islands Grand Cayman capital building a four storey No. 847 mailbox

Applicant before: ALIBABA GROUP HOLDING Ltd.

GR01 Patent grant
GR01 Patent grant