Generation method and device of target page code
By analyzing the container component location information and layout type of the target page, and using pre-written template code to generate target page code, the problem of inefficient target page code generation in private cloud is solved and more efficient code generation is achieved.
Patent Information
- Application Number
- CN202310659931.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-05
- Publication Date
- 2024-12-06
AI Technical Summary
In private cloud scenarios, the generation efficiency of target page code is low because the existing technology requires front-end staff to convert prototype pages into front-end page codes through encoding, resulting in inefficiency.
By obtaining the target page, parsing the location information of the container element, determining the container layout type, and generating the target page code based on the type call the pre-written container layout template code, reducing the coding requirement for container layout.
Improve the generation efficiency of target page code, reduce coding steps, and improve work efficiency.
Smart Images

Figure CN119088348A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud technology, and in particular to a method and device for generating a target page code. Background Art
[0002] In the private cloud scenario, there are a large number of pages with similar display styles. Currently, these pages need to be developed by coding with reference to the prototype design page. In the prior art, after the product manager designs the prototype page through the prototype design tool, the front-end and back-end staff understand the product requirements and prototype design, and the front-end staff converts the prototype page into the front-end page code through coding. This method is inefficient in generating codes for various similar target pages in the private cloud scenario.
[0003] That is, the generation efficiency of the target page code in the prior art is low. Summary of the invention
[0004] The embodiments of the present application provide a method and device for generating a target page code, which can improve the generation efficiency of the target page code.
[0005] In a first aspect, the method for generating a target page code provided by the present application includes:
[0006] Get the target page;
[0007] Parsing the target page to obtain location information of the container element on the target page;
[0008] Determining a container layout type of the target page based on the position information of the container element, wherein the container layout type is a layout type between each container element;
[0009] Determine, based on the container layout type of the target page, a container layout template code that matches the container layout type of the target page;
[0010] Generate target page code based on the container layout template code;
[0011] The target page code is returned to the private cloud.
[0012] In a second aspect, the target page code generation device provided by the present application includes:
[0013] Page acquisition module, used to acquire the target page;
[0014] A page parsing module, used to parse the target page to obtain location information of the container element on the target page;
[0015] A layout determination module, configured to determine a container layout type of the target page based on the position information of the container element, wherein the container layout type is a layout type between various container elements;
[0016] A template determination module, configured to determine, based on the container layout type of the target page, a container layout template code that matches the container layout type of the target page;
[0017] A code generation module is used to generate target page code based on the container layout template code.
[0018] In an optional embodiment, the layout determination module is used to:
[0019] Determine any two container elements in the target page as a container element group to obtain at least one container element group;
[0020] Determine the container layout type of the container element group based on the position information of two container elements in the container element group, and obtain the container layout type of each container element group;
[0021] The container layout type of the target page is determined based on the container layout types of each of the container component groups.
[0022] In an optional embodiment, the layout type is a horizontal layout type, a vertical layout type, or a row and column layout type, and the layout determination module is used to:
[0023] If the container layout types of all the container component groups are horizontal layout types, determining that the container layout type of the target page is a horizontal layout type;
[0024] If the container layout types of all the container component groups are vertical layout types, determining that the container layout type of the target page is a vertical layout type;
[0025] If the container layout types of the container component groups are neither the horizontal layout type nor the vertical layout type, it is determined that the container layout type of the target page is the row-column layout type.
[0026] In an optional embodiment, the layout determination module is used to:
[0027] Determine, according to the position information of the two container elements, a container transverse distance difference in the transverse direction of the two container elements and a container longitudinal distance difference in the longitudinal direction of the two container elements, wherein the container transverse distance difference is a distance difference between the left borders of the two container elements; and the container longitudinal distance difference is a distance difference between the upper borders of the two container elements;
[0028] If the container transverse distance difference is less than a first preset value, the container layout type of the container element group is determined to be a longitudinal layout type; if the container longitudinal distance difference is less than a second preset value, the container layout type of the container element group is determined to be a transverse layout type; if the container transverse distance difference is not less than the first preset value, and the container longitudinal distance difference is not less than the second preset value, the container layout type of the container element group is determined to be a row-column layout type.
[0029] In an optional embodiment, the code generation module is used to:
[0030] Obtaining a container template code of the container element;
[0031] The container template code of the container element is added to the container layout template code to obtain the target page code.
[0032] In an optional embodiment, the code generation module is used to:
[0033] Acquire location information of atomic elements obtained when parsing the target page, wherein each of the atomic elements is located in one of the container elements;
[0034] Determining an atomic component set of the container component based on the position information of the container component and the position information of the atomic component, wherein each atomic component in the atomic component set of the container component is located in the container component;
[0035] Determine the atomic layout type of the container element based on the position information of the atomic element in the atomic element set of the container element, the atomic layout type being the layout type between the atomic elements;
[0036] Determine the atomic layout template code of the container element based on the atomic layout type of the container element;
[0037] The container template code of the container element is determined based on the atomic layout template code of the container element to obtain the container template code of the container element.
[0038] In an optional embodiment, the code generation module is used to:
[0039] Obtaining the atomic template code of the atomic element;
[0040] Adding the atomic template code of the atomic element in the atomic element set of the container element to the atomic layout template code of the container element to obtain the added layout template code of the container element;
[0041] The added layout template code of the container element is added to the container blank template code of the container element to obtain the container template code of the container element.
[0042] In an optional embodiment, the code generation module is used to:
[0043] Obtaining text information in the atomic element;
[0044] Determining component attribute information of the atomic component based on text information in the atomic component, wherein the component attribute information is used to set a display mode of the atomic component;
[0045] Obtaining an atomic blank template code of the atomic element;
[0046] The text information and component attribute information in the atomic component are added to the atomic blank template code of the atomic component to obtain the atomic template code of the atomic component.
[0047] In a third aspect, the electronic device provided in the present application includes a memory and a processor, the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the steps in the method for generating the target page code provided in the present application.
[0048] In a fourth aspect, the computer-readable storage medium provided in the present application stores a plurality of instructions, which are suitable for loading by a processor to implement the steps in the method for generating the target page code provided in the present application.
[0049] In a fifth aspect, the computer program product provided in the present application includes a computer program or instructions, which, when executed by a processor, implements the steps in the method for generating the target page code provided in the present application.
[0050] In the present application, compared with the related art, after obtaining the target page, the container elements on the target page are parsed, and the container layout type between the container elements is determined according to the position information of the container elements, and then the pre-written container layout template code is called according to the container layout type, and the target page code is generated using the pre-written container layout template code. Only a small amount of container layout template code needs to be written in advance and directly called when generating the target page. There is no need to encode the container layout again, thereby improving the generation efficiency of the target page code. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0052] Figure 1 It is a scenario diagram of a system for generating target page code provided in an embodiment of the present application;
[0053] Figure 2 It is a flowchart of a method for generating a target page code provided in an embodiment of the present application;
[0054] Figure 3 is a schematic diagram of a target page provided in an embodiment of the present application;
[0055] Figure 4 It is a flow chart of determining the container layout type of the target page based on the position information of the container element in the method for generating the target page code provided by the embodiment of the present application;
[0056] Figure 5 is another schematic diagram of a target page provided in an embodiment of the present application;
[0057] Figure 6 It is a schematic diagram of a process of obtaining a container template code of a container element in a method for generating a target page code provided in an embodiment of the present application;
[0058] Figure 7 is another flowchart of the method for generating a target page code provided in an embodiment of the present application;
[0059] Figure 8 It is a structural schematic diagram of a device for generating a target page code provided in an embodiment of the present application;
[0060] Fig. 9 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] It should be noted that the principles of the present application are illustrated by implementing them in an appropriate computing environment. The following description is based on the illustrated specific embodiments of the present application and should not be considered as limiting other specific embodiments of the present application that are not described in detail herein.
[0062] In the following description of the present application, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0063] In the following description of the present application, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0064] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0065] In order to improve the efficiency of target page code generation, the embodiments of the present application provide a target page code generation method, a target page code generation device, an electronic device, a computer readable storage medium, and a computer program product. The target page code generation method can be executed by the target page code generation device, or by an electronic device integrated with the target page code generation device.
[0066] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0067] Please refer to Figure 1 , the present application also provides a target page code generation system, such as Figure 1 As shown, the target page code generation system includes an electronic device 100, and the target page code generation device provided by the present application is integrated in the electronic device 100. For example, the electronic device 100 can obtain the target page; parse the target page to obtain the location information of the container element on the target page; determine the container layout type of the target page based on the location information of the container element, wherein the container layout type is the layout type between each container element; determine the container layout template code matching the container layout type of the target page based on the container layout type of the target page; and generate the target page code based on the container layout template code.
[0068] Among them, the electronic device 100 can be any device equipped with a processor and has processing capabilities, such as mobile electronic devices with processors such as smart phones, tablet computers, PDAs, laptops, smart speakers, or fixed electronic devices with processors such as desktop computers, televisions, servers, industrial equipment, etc.
[0069] The target page code generation system also includes a cloud system, and the electronic device 100 communicates with the private cloud through a network. The cloud system can be a public cloud, a private cloud, or a hybrid cloud, etc.
[0070] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.
[0071] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.
[0072] A private cloud is a cloud infrastructure with software and hardware resources created within a firewall so that departments within an organization or enterprise can share resources within the data center. In addition to hardware resources, creating a private cloud generally also requires cloud device Infrastructure as a Service (IaaS) software.
[0073] Private cloud computing also includes three levels: cloud hardware, cloud platform, and cloud service. The difference is that cloud hardware is the user's own personal computer or server, not the cloud computing vendor's data center. The purpose of cloud computing vendors to build data centers is to provide public cloud services to millions of users, so they need to have tens of millions of servers. Private cloud computing only serves friends and relatives for individuals, and only serves employees, customers, and suppliers for enterprises. Therefore, an individual or enterprise's own personal computer or server is sufficient to provide cloud services.
[0074] In addition, if Figure 1As shown, the target page code generation system may also include a memory 200 for storing original data, intermediate data and result data in the image processing process. For example, the electronic device 100 calls the corresponding interface of the private cloud to obtain the target page (original data) published on the private cloud, parses the target page, and stores the obtained location information of the container elements on the target page, the container layout type of the target page determined based on the location information of the container elements, the container layout template code (intermediate data) that matches the container layout type of the target page determined based on the container layout type of the target page, and the target page code (result data) generated based on the container layout template code in the memory 200.
[0075] In the embodiment of the present application, the memory 200 can be a cloud storage. Cloud storage is a new concept extended and developed from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as the storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.
[0076] At present, the storage method of the storage system is: create a logical volume, and when creating a logical volume, allocate physical storage space for each logical volume. The physical storage space may be composed of disks of a storage device or several storage devices. The client stores data on a logical volume, that is, stores the data on the file system. The file system divides the data into many parts, each of which is an object. The object contains not only data but also additional information such as data identification (ID entity, ID). The file system writes each object into the physical storage space of the logical volume, and the file system records the storage location information of each object, so that when the client requests to access the data, the file system can allow the client to access the data according to the storage location information of each object.
[0077] The process of the storage system allocating physical storage space to a logical volume is as follows: based on the estimated capacity of the objects stored in the logical volume (this estimate often has a large margin relative to the actual capacity of the objects to be stored) and the grouping of the Redundant Array of Independent Disks (RAID), the physical storage space is divided into stripes in advance. A logical volume can be understood as a stripe, thereby allocating physical storage space to the logical volume.
[0078] It should be noted that Figure 1The scenario diagram of the target page code generation system shown is merely an example. The target page code generation system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art will appreciate that, with the evolution of the target page code generation system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is equally applicable to similar technical problems.
[0079] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0080] Please refer to Figure 2 , Figure 2 is a flow chart of a method for generating a target page code provided in an embodiment of the present application, such as Figure 2 As shown, the process of the method for generating the target page code provided by this application is as follows:
[0081] 201. Get the target page.
[0082] In the embodiment of the present application, the target page is an HTML page or XML page uploaded by the staff. Hypertext Markup Language (HTML) is a markup language. It includes a series of tags, through which the document format on the network can be unified, so that scattered Internet resources can be connected into a logical whole. The text written in HTML language is HTML text, which is a descriptive text composed of HTML commands. HTML commands can describe text, graphics, animations, sounds, tables, links, etc.
[0083] In the embodiment of the present application, the target page may be a private cloud page uploaded by the staff on the private cloud, and the private cloud page may be an html page or an xml page, etc. The corresponding interface of the private cloud is called to obtain the private cloud page published on the private cloud to obtain the target page.
[0084] Extensible Markup Language (XML) is a subset of the standard general markup language. It can be used to mark data and define data types. It is a source language that allows users to define their own markup language. XML has the advantages of good extensibility, separation of content and form, strict grammatical requirements, and good value preservation.
[0085] In a specific embodiment, after the designer designs the prototype page using the prototype page design tool, the prototype page designed using the prototype page design tool is published on the private cloud in the format of an HTML web page, and the electronic device obtains the target page. For example, the designer uses Axure RP software to design the prototype page.
[0086] Axure RP: is a professional rapid prototyping tool that allows experts who are responsible for defining requirements and specifications, designing functions and interfaces to quickly create wireframes, flow charts, prototypes and specification documents for application software or Web sites. Axure components are the elements required for the Axure PR prototyping tool to design pages, such as tables, input boxes, drop-down boxes, etc., which are collectively referred to as components.
[0087] For example, Figure 3 A schematic diagram of an embodiment of a target page.
[0088] 202. Parse the target page to obtain location information of the container component on the target page.
[0089] In the embodiment of the present application, the position information of the container element includes the horizontal distance difference between the left edge of the container element and the left edge of the page, the vertical distance difference between the upper edge of the container element and the upper edge of the page, the height of the container element, and the width of the container element. Figure 3 As shown, the horizontal distance difference between the left border of the container element and the left border of the page is left1, the vertical distance difference between the top border of the container element and the top border of the page is top1, the height of the container element is height1, and the width of the container element is width1.
[0090] In the embodiment of the present application, the designer uses Axure RP software to define a set of custom Axure component libraries based on the style of the target page to design the target page. In the custom Axure component library, each component has a unique attribute tag, component location information, etc. For example, the attribute tag of the component includes groupName, and groupName is used to mark the type of the component. For example, groupName is table, which means that the component belongs to a container component, and groupName is column, which means that the component belongs to an atomic component, and the atomic component is located in the container component. The location information and component type of the container component on the target page can be obtained by parsing the attribute tag of the component, and the component type belonging to the container is determined as a container component, and the component type belonging to the atom is determined as an atomic component. Specifically, the target page can be parsed using a preset html parser to obtain the location information of the container component on the target page. The preset html parser can be htmlParse or other parsers. htmlParse is an html document parsing tool based on the windwos platform, which can quickly build a DOM tree, thereby easily realizing the crawling of web page elements. The DOM tree is a node tree of an HTML document. Each node is described by three values: tag, attribute, and text.
[0091] Furthermore, by parsing the target page, the text information and display attributes in each container component can be obtained. The display attribute indicates whether the text information in the container component is displayed. If the display attribute is true, it indicates display.
[0092] like Figure 3 As shown, the target page is parsed to obtain three container components, namely, container component a, container component b, and container component c.
[0093] Furthermore, after parsing the target page, each component may have abnormal phenomena, such as some elements are not displayed, and some elements are just empty elements without any content, and each component needs to be cleaned. In a specific embodiment, each component obtained by parsing is obtained, and whether there is overlap between the two components is determined based on the position information of the two components. If there is overlap between the two components, the display levels of the two components are obtained, and the component with the lower display level of the two components is eliminated.
[0094] 203. Determine a container layout type of the target page based on the position information of the container element.
[0095] The container layout type is the layout type between each container element. The layout type may include a horizontal layout type, a vertical layout type, and a row and column layout type, which may be set according to specific circumstances.
[0096] In the embodiment of the present application, a preset mapping relationship between the position information of each container element and the layout type may be preset, and the container layout type of the target page may be determined according to the position information of the container element and the preset mapping relationship.
[0097] 204. Determine, based on the container layout type of the target page, a container layout template code that matches the container layout type of the target page.
[0098] In the embodiment of the present application, the staff pre-writes the layout template code of each layout type, and different layout types correspond to different layout template codes. For example, the layout template code of the horizontal layout type is layout template code h, the layout template code of the vertical layout type is layout template code z, and the layout template code of the row and column layout type is layout template code z. After obtaining the container layout type of the target page, the container layout template code corresponding to the layout type can be obtained.
[0099] 205. Generate target page code based on the container layout template code.
[0100] In a specific embodiment, the container layout template code is used as the target page code. In other embodiments, other codes may be added to the container layout template code to use it as the target page code.
[0101] In another specific embodiment, in order to automatically generate more codes, generating target page codes based on container layout template codes may include:
[0102] (1) Get the container template code of the container element.
[0103] Specifically, the container template code is pre-written by the staff and stored on the private cloud. The corresponding interface on the private cloud is called to obtain the container template code of each container component published on the private cloud. For example, the container component corresponds to the container template code a, the container component b corresponds to the container template code b, and the container component c corresponds to the container template code c.
[0104] For example, the structure of the container template code is as follows:
[0105]
[0106] (2) Add the container template code of the container element to the container layout template code to obtain the target page code.
[0107] Specifically, a code adding position for a container element is reserved in the container layout template code, and the container template code of each container element is added to the code adding position of the container layout template code to obtain the target page code.
[0108] Furthermore, the target page code is returned to the private cloud. Specifically, the target page code is returned to the private cloud, and other staff can obtain the target page code from the private cloud and then continue to develop.
[0109] For further information, see Figure 4 In order to improve the accuracy of layout type determination, the container layout type of the target page is determined based on the location information of the container element, including 301-303:
[0110] 301. Determine any two container components in the target page as a container component group to obtain at least one container component group.
[0111] by Figure 3 Taking the three container components in as an example, the combination of the three container components can obtain three container component groups. Container component a and container component b form a container component group, container component a and container component c form a container component group, and container component b and container component c form a container component group.
[0112] 302. Determine a container layout type of the container component group based on position information of two container components in the container component group, and obtain a container layout type of each container component group.
[0113] In a specific embodiment, a preset mapping relationship between the position information of the two container elements and the layout type may be preset, and the container layout types of the two target pages may be determined according to the position information of the two container elements and the preset mapping relationship.
[0114] In another specific embodiment, in order to more accurately determine the container layout types of the two target pages, the container layout type of the container element group is determined based on the position information of the two container elements in the container element group, and the container layout type of each container element group is obtained, including:
[0115] (1) Determine a container transverse distance difference between the two container elements in the transverse direction and a container longitudinal distance difference between the two container elements in the longitudinal direction according to the position information of the two container elements, wherein the container transverse distance difference is the distance difference between the left boundaries of the two container elements; and the container longitudinal distance difference is the distance difference between the upper boundaries of the two container elements.
[0116] In the embodiment of the present application, the horizontal distance difference between the left border of the container element and the left border of the page is left1, the vertical distance difference between the top border of the container element and the top border of the page is top1, the height of the container element is height1, and the width of the container element is width1. The difference between the horizontal distance difference left1 of the two container elements is determined as the horizontal distance difference of the container; the difference between the vertical distance difference top1 of the two container elements is determined as the vertical distance difference of the container.
[0117] (2) If the container horizontal distance difference is less than a first preset value, the container layout type of the container element group is determined to be a vertical layout type; if the container vertical distance difference is less than a second preset value, the container layout type of the container element group is determined to be a horizontal layout type; if the container horizontal distance difference is not less than the first preset value, and the container vertical distance difference is not less than the second preset value, the container layout type of the container element group is determined to be a row-column layout type.
[0118] In a specific embodiment, the first preset value and the second preset value are both a distance of 5 pixels. In other embodiments, the first preset value and the second preset value may also be other distances, which is not limited in the present application.
[0119] 303. Determine a container layout type of the target page based on the container layout types of each container component group.
[0120] In a specific embodiment, if the container layout types of all container element groups are horizontal layout types, the container layout type of the target page is determined to be the horizontal layout type; if the container layout types of all container element groups are vertical layout types, the container layout type of the target page is determined to be the vertical layout type; if the container layout types of all container element groups are neither horizontal layout types nor vertical layout types, the container layout type of the target page is determined to be the row-column layout type.
[0121] like Figure 5 As shown, in some scenarios, there are some atomic components in the container component. In order to generate complete code, combined with Figure 5 and Figure 6 , get the container template code of the container element, which may include 401-405:
[0122] 401. Obtain location information of atomic components obtained when parsing the target page.
[0123] Each atomic element is located in one of the container elements.
[0124] Specifically, the target page is parsed to obtain multiple components, among which there are both container components and atomic components. The type of the component can be determined according to the groupName of the component. If the groupName is table, it means that the component belongs to the container component, and if the groupName is column, it means that the component belongs to the atomic component, and the atomic component is located in the container component.
[0125] Furthermore, by parsing the target page, the text information and display attributes of each atomic component can be obtained. The display attribute indicates whether the text information in the atomic component is displayed. If the display attribute is true, it indicates display.
[0126] 402. Determine an atomic component set of the container component based on the position information of the container component and the position information of the atomic component.
[0127] Wherein, each atomic component in the atomic component set of the container component is located in the container component.
[0128] In a specific embodiment, the horizontal distance difference between the left border of the container element and the left border of the page is left1, the vertical distance difference between the top border of the container element and the top border of the page is top1, the height of the container element is height1, and the width of the container element is width1. The horizontal distance difference between the left border of the atomic element and the left border of the page is left2, the vertical distance difference between the top border of the atomic element and the top border of the page is top2, the height of the atomic element is height2, and the width of the atomic element is width2.
[0129] If the container page horizontal distance difference between the left border of the container element and the left border of the page is left1, which is not greater than the atomic page horizontal distance difference between the left border of the atomic element and the left border of the page is left2, and the container page horizontal distance difference between the right border of the container element and the left border of the page is not less than the atomic page horizontal distance difference between the right border of the atomic element and the left border of the page, and the container page vertical distance difference between the upper border of the container element and the upper border of the page is top1, which is not greater than the atomic page vertical distance difference between the upper border of the atomic element and the upper border of the page is top2, and the container page vertical distance difference between the lower border of the container element and the upper border of the page is not less than the atomic page vertical distance difference between the lower border of the atomic element and the upper border of the page, then it is determined that the atomic element is located inside the container element.
[0130] If the container component and the atomic component satisfy the containment relationship, then the container component and the atomic component satisfy the following formula:
[0131] left1≤left2;
[0132] left1+width1≥left2+width2;
[0133] top1≤top2;
[0134] top1+height1≥top2+height2.
[0135] like Figure 5 As shown, the target page is parsed to obtain 3 container elements and 9 atomic elements. The 3 container elements are: container element a, container element b, and container element c. The 9 atomic elements are: atomic element a1, atomic element a2, atomic element a3, atomic element b1, atomic element b2, atomic element b3, atomic element c1, atomic element c2, and atomic element c3. In other embodiments, more container elements and atomic elements may be included, which will not be described in detail.
[0136] 403. Determine the atomic layout type of the container component based on the position information of the atomic components in the atomic component set of the container component.
[0137] The atomic layout type is a layout type between atomic elements, which may be a horizontal layout type, a vertical layout type, or a row-column layout type.
[0138] In a specific embodiment, determining the atomic layout type between atomic elements in the atomic element set of the container element based on the position information of the atomic elements in the atomic element set of the container element includes:
[0139] (1) Any two atomic elements among the atomic elements are determined as an atomic element group to obtain an atomic element group.
[0140] by Figure 5 For example, the container component a contains 3 atomic components. The combination of the 3 atomic components can obtain 3 atomic component groups. The atomic component a1 and the atomic component a2 form an atomic component group, the atomic component a2 and the atomic component a3 form an atomic component group, and the atomic component a1 and the atomic component a3 form an atomic component group.
[0141] (2) Determine the layout type of the atomic element group based on the position information of two atomic elements in the atomic element group, and obtain the layout type of each atomic element group.
[0142] In a specific embodiment, a preset mapping relationship between the position information of two atomic elements and the layout type may be preset, and the atomic layout type between the two atomic elements may be determined according to the position information of the two atomic elements and the preset mapping relationship.
[0143] In another specific embodiment, in order to more accurately determine the atomic layout type between two atomic elements, the layout type of the atomic element group is determined based on the position information of the two atomic elements in the atomic element group, and the layout type of each atomic element group is obtained, including: determining the atomic lateral distance difference in the lateral direction of the two atomic elements and the atomic longitudinal distance difference in the longitudinal direction of the two atomic elements according to the position information of the two atomic elements, the atomic lateral distance difference is the distance difference between the left boundaries of the two atomic elements; the atomic longitudinal distance difference is the distance difference between the upper boundaries of the two atomic elements. If the atomic lateral distance difference is less than the first preset value, the layout type of the atomic element group is determined to be a longitudinal layout type; if the atomic longitudinal distance difference is less than the second preset value, the layout type of the atomic element group is determined to be a lateral layout type; if the atomic lateral distance difference is not less than the first preset value, and the atomic longitudinal distance difference is not less than the second preset value, the layout type of the atomic element group is determined to be a row and column layout type. Wherein, the first preset value and the second preset value are both distances of 5 pixels. In other embodiments, the first preset value and the second preset value may also be other distances, which are not limited in this application.
[0144] (3) Determine the atomic layout type between atomic elements based on the layout type of each atomic element group.
[0145] In a specific embodiment, if all atomic element groups are of horizontal layout type, then the atomic layout type between the atomic elements is determined to be the horizontal layout type; if all atomic element groups are of vertical layout type, then the atomic layout type between the atomic elements is determined to be the vertical layout type; if all atomic element groups are neither of horizontal layout type nor of vertical layout type, then the atomic layout type between the atomic elements is determined to be the row-column layout type.
[0146] like Figure 5 As shown, in container element a, atomic element a1 and atomic element a2 are of horizontal layout type, atomic element a1 and atomic element a3 are of vertical layout type, atomic element a2 and atomic element a3 are of row and column layout type, and each atomic element group in container element a is not all of horizontal layout type, nor is it all of vertical layout type. Atomic element a1, atomic element a2 and atomic element a3 in container element a are of row and column layout type. Based on the same principle, atomic element b1, atomic element b2 and atomic element b3 in container element b are of vertical layout type. Atomic element c1, atomic element c2 and atomic element c3 in container element c are of horizontal layout type. The layout type between the three container elements is row and column.
[0147] 404. Determine the atomic layout template code of the container component based on the atomic layout type of the container component.
[0148] The mapping relationship between the atomic layout type and the layout template code between the atomic components of the container component can be preset. The atomic layout template code can be pre-written by the staff and stored in the private cloud. The atomic layout template code matching the container component can be called by calling the corresponding interface of the private cloud.
[0149] 405. Determine a container template code of the container component based on the atomic layout template code of the container component.
[0150] In a specific embodiment, the atomic layout template code of the container element is determined as the container template code of the container element, and the container template code of each container element is obtained.
[0151] In another specific embodiment, determining the container template code of the container element based on the atomic layout template code of the container element to obtain the container template code of the container element includes:
[0152] (1) Obtain the atomic template code of the atomic component.
[0153] In a specific embodiment, an interface corresponding to the private cloud is called to obtain the atomic template code of each atomic element published on the private cloud platform.
[0154] (2) Adding the atomic template code of the atomic element in the atomic element set of the container element to the atomic layout template code of the container element to obtain the added layout template code of the container element.
[0155] (3) The added layout template code of the container component is added to the container blank template code of the container component to obtain the container template code of the container component.
[0156] In the embodiment of the present application, the type of the container element may be a table container type, a label container type, etc. Different container blank template codes are determined according to different types of container elements.
[0157] Furthermore, in order to improve the accuracy of the atomic template code, the atomic template code of each atomic element is obtained, including:
[0158] (1) Get the text information within the atomic component.
[0159] (2) Determine the component attribute information of the atomic component based on the text information in the atomic component.
[0160] Among them, the component attribute information is used to set the display mode of the atomic component.
[0161] Specifically, keywords are extracted from the text information in the atomic component, and the component attribute information of the atomic component is determined based on the extracted keywords. The correspondence between keywords and component attribute information can be preset. For example, when the extracted keywords include the first type of keywords, this atomic component is likely to have more content, and the component attribute information of the atomic component is determined as follows: the column width is widened, the text display is omitted, and the text is displayed when the mouse is placed on the text. The first type of keywords can be "details", "description", "instructions", etc. When the extracted keywords include the second type of keywords, this atomic component is likely to be a column that displays time, and the component attribute information of the atomic component is determined as follows: the atomic component is displayed in the time column. The second type of keywords include "date", "time", etc. When the extracted keywords include the third type of keywords, this atomic component is likely to be a column that displays the amount, and the component attribute information of the atomic component is determined as follows: the atomic component is displayed in the amount column. The third type of keywords include "price", "yuan", etc.
[0162] (3) Obtain the atomic blank template code of the atomic component.
[0163] The types of atomic components can be buttons, drop-down boxes, table columns, input boxes, etc. The atomic blank template codes of various atomic components are pre-written and stored in the private cloud, and the corresponding interface of the private cloud is called to obtain the atomic blank template codes of various atomic components from the private cloud.
[0164] (4) Add the text information and component attribute information in the atomic component to the atomic blank template code of the atomic component to obtain the atomic template code of the atomic component.
[0165] For further information, see Figure 7 , Figure 7 : is a flow chart of another embodiment of the method for generating the target page code provided in the embodiment of the present application. The flow chart of the method for generating the target page code provided in the present application is as follows:
[0166] 501. Call the corresponding interface of the private cloud to obtain the private cloud page published on the private cloud.
[0167] In the embodiment of the present application, the target page is a private cloud page. The schematic diagram of the private cloud page is as follows: Figure 5 shown.
[0168] 502. Parse the private cloud page to obtain location information of container components, location information of atomic components, and text information on the private cloud page.
[0169] like Figure 5As shown, the private cloud page is parsed to obtain 3 container components and 9 atomic components. The 3 container components are: container component a, container component b, and container component c. The 9 atomic components are: atomic component a1, atomic component a2, atomic component a3, atomic component b1, atomic component b2, atomic component b3, atomic component c1, atomic component c2, and atomic component c3. For example, the text information in atomic component a1 is "Details".
[0170] 503. Determine the container layout type of the private cloud page based on the location information of the container element.
[0171] Specifically, the specific steps of 503 can refer to the specific steps of 301-303, which will not be repeated here.
[0172] 504. Determine an atomic component set of the container component based on the position information of the container component and the position information of the atomic component.
[0173] Wherein, each atomic component in the atomic component set of the container component is located in the container component.
[0174] Specifically, the specific steps of 504 can refer to the specific steps of 402, which will not be repeated here.
[0175] 505. Determine the atomic layout type of the container component based on the position information of the atomic components in the atomic component set of the container component.
[0176] Specifically, the specific steps of 505 can refer to the specific steps of 403, which will not be repeated here.
[0177] 506. Determine the atomic layout template code of the container component based on the atomic layout type of the container component.
[0178] The mapping relationship between the atomic layout type and the layout template code between the atomic components of the container component can be preset. The atomic layout template code can be pre-written by the staff and stored in the private cloud. The atomic layout template code matching the container component can be called by calling the corresponding interface of the private cloud.
[0179] 507. Obtain the atomic template code of each atomic component.
[0180] In a specific embodiment, an interface corresponding to the private cloud is called to obtain the atomic template code of each atomic element published on the private cloud platform.
[0181] For example, the code of the atomic template code of the atomic component is as follows:
[0182]
[0183] 508. Add the atomic template code of the atomic element in the atomic element set of the container element to the atomic layout template code of the container element to obtain the added layout template code of the container element.
[0184] 509. Add the added layout template code of the container component to the container blank template code of the container component to obtain the container template code of the container component.
[0185] In the embodiment of the present application, the type of the container element may be a table container type, a label container type, etc. Different container blank template codes are determined according to different types of container elements.
[0186] For example, the container blank template code of the container component is as follows:
[0187]
[0188]
[0189] Add the atomic template code of the atomic component to the atomic layout template code of the container component, and then add it to the blank template code. The container template code of the obtained container component is as follows:
[0190]
[0191] S510. Add the container template code of the container element to the container layout template code to obtain the private cloud page code.
[0192] S511. Return the private cloud page code to the private cloud.
[0193] In order to better implement the target page code generation method provided in the embodiment of the present application, the embodiment of the present application also provides a target page code generation device based on the target page code generation method. The meanings of the terms are the same as those in the target page code generation method. For specific implementation details, please refer to the description in the above method embodiment.
[0194] Please refer to Figure 8 , Figure 8 The schematic diagram of the structure of the target page code generation device provided in the embodiment of the present application, the target page code generation device may include a page acquisition module 801, a page parsing module 802, a layout determination module 803, a template determination module 804, and a code generation module 805, wherein:
[0195] The page acquisition module 801 is used to acquire the target page;
[0196] The page parsing module 802 is used to parse the target page and obtain the location information of the container element on the target page;
[0197] A layout determination module 803 is used to determine the container layout type of the target page based on the position information of the container element, wherein the container layout type is the layout type between each container element;
[0198] A template determination module 804 is used to determine a container layout template code matching the container layout type of the target page based on the container layout type of the target page;
[0199] The code generation module 805 is used to generate target page code based on the container layout template code.
[0200] Furthermore, the target page code generation device includes a return module, and the return module is used to return the target page code to the private cloud.
[0201] In an optional embodiment, the layout determination module is used to:
[0202] Determine any two container elements in the target page as a container element group to obtain at least one container element group;
[0203] Determine the container layout type of the container component group based on the position information of two container components in the container component group, and obtain the container layout type of each container component group;
[0204] The container layout type of the target page is determined based on the container layout types of the respective container component groups.
[0205] In an optional embodiment, the layout type is a horizontal layout type, a vertical layout type, or a row and column layout type, and the layout determination module is used to:
[0206] If the container layout types of all container component groups are horizontal layout types, then determining that the container layout type of the target page is a horizontal layout type;
[0207] If the container layout types of all container component groups are vertical layout types, then determining the container layout type of the target page to be a vertical layout type;
[0208] If the container layout types of the container component groups are neither the horizontal layout type nor the vertical layout type, the container layout type of the target page is determined to be the row-column layout type.
[0209] In an optional embodiment, the layout determination module is used to:
[0210] Determine, according to the position information of the two container elements, a container transverse distance difference in the transverse direction of the two container elements and a container longitudinal distance difference in the longitudinal direction of the two container elements, wherein the container transverse distance difference is a distance difference between the left borders of the two container elements; and the container longitudinal distance difference is a distance difference between the upper borders of the two container elements;
[0211] If the container horizontal distance difference is less than the first preset value, the container layout type of the container element group is determined to be the vertical layout type; if the container vertical distance difference is less than the second preset value, the container layout type of the container element group is determined to be the horizontal layout type; if the container horizontal distance difference is not less than the first preset value, and the container vertical distance difference is not less than the second preset value, the container layout type of the container element group is determined to be the row-column layout type.
[0212] In an optional embodiment, the code generation module is used to:
[0213] Get the container template code of the container element;
[0214] Add the container template code of the container component to the container layout template code to obtain the target page code.
[0215] In an optional embodiment, the code generation module is used to:
[0216] Acquire location information of atomic elements obtained when parsing the target page, wherein each atomic element is located in one of the container elements;
[0217] Determine an atomic component set of the container component based on the position information of the container component and the position information of the atomic component, wherein each atomic component in the atomic component set of the container component is located in the container component;
[0218] Determine the atomic layout type of the container component based on the position information of the atomic components in the atomic component set of the container component, where the atomic layout type is the layout type between the atomic components;
[0219] Determine the atomic layout template code of the container component based on the atomic layout type of the container component;
[0220] The container template code of the container component is determined based on the atomic layout template code of the container component to obtain the container template code of the container component.
[0221] In an optional embodiment, the code generation module is used to:
[0222] Get the atomic template code of the atomic component;
[0223] Adding the atomic template code of the atomic element in the atomic element set of the container element to the atomic layout template code of the container element to obtain the added layout template code of the container element;
[0224] The added layout template code of the container component is added to the container blank template code of the container component to obtain the container template code of the container component.
[0225] In an optional embodiment, the code generation module is used to:
[0226] Get the text information in the atomic component;
[0227] Determining component attribute information of the atomic component based on text information in the atomic component, wherein the component attribute information is used to set a display mode of the atomic component;
[0228] Get the atomic blank template code of the atomic component;
[0229] The text information and component attribute information in the atomic component are added to the atomic blank template code of the atomic component to obtain the atomic template code of the atomic component.
[0230] The specific implementation of each of the above modules can be found in the previous embodiments and will not be described in detail here.
[0231] In this embodiment, the acquisition module 801 first acquires the target page; then the page parsing module 802 parses the target page to obtain the location information of the container elements on the target page; then the layout determination module 803 determines the container layout type of the target page based on the location information of the container elements, wherein the container layout type is the layout type between each container element; then the template determination module 804 determines the container layout template code matching the container layout type of the target page based on the container layout type of the target page; then the code generation module 805 generates the target page code based on the container layout template code. Compared with the related art, after acquiring the target page, the container elements on the target page are parsed, and the container layout type between the container elements is determined according to the location information of the container elements, and then the pre-written container layout template code is called according to the container layout type, and the target page code is generated using the pre-written container layout template code, and only a small amount of container layout template code needs to be pre-written, and it is directly called when generating the target page, and there is no need to encode the container layout again, thereby improving the generation efficiency of the target page code.
[0232] Please refer to Fig. 9 , Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0233] The electronic device may include components such as a processor 101 with one or more processing cores, a memory 102 with one or more computer-readable storage media, a power supply 103, and an input unit 104. Those skilled in the art will appreciate that Fig. 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0234] The processor 101 is the control center of the electronic device, which uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 102, and calling data stored in the memory 102. Optionally, the processor 101 may include one or more processing cores; optionally, the processor 101 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 101.
[0235] The memory 102 can be used to store software programs and modules. The processor 101 executes various functional applications and data processing by running the software programs and modules stored in the memory 102. The memory 102 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 102 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 102 may also include a memory controller to provide the processor 101 with access to the memory 102.
[0236] The electronic device also includes a power supply 103 for supplying power to each component. Optionally, the power supply 103 can be logically connected to the processor 101 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 103 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0237] The electronic device may further include an input unit 104, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0238] Although not shown, the electronic device may also include a display unit, an image acquisition element, etc., which will not be described in detail here. Specifically in this embodiment, the processor 101 in the electronic device will load the executable code corresponding to one or more computer programs into the memory 102 according to the following instructions, and the processor 101 will execute the steps in the method for generating the target page code provided by the present application, such as:
[0239] Get the target page;
[0240] Parse the target page to obtain the location information of the container element on the target page;
[0241] Determining a container layout type of the target page based on the position information of the container element, wherein the container layout type is a layout type between each container element;
[0242] Determine, based on the container layout type of the target page, a container layout template code that matches the container layout type of the target page;
[0243] Generates target page code based on container layout template code.
[0244] It should be noted that the electronic device provided in the embodiment of the present application and the method for generating the target page code in the above embodiment belong to the same concept, and its specific implementation process is detailed in the above related embodiments and will not be repeated here.
[0245] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program stored therein is executed on a processor of an electronic device provided in an embodiment of the present application, the processor of the electronic device executes the steps in the method for generating a target page code provided in the present application. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0246] The present application also provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes various optional implementations of the above-mentioned method for generating a target page code.
[0247] The above is a detailed introduction to a method and device for generating a target page code provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
[0248] It should be noted that when the above embodiments of the present application are applied to specific products or technologies, the relevant data of the user is involved, and the user's permission or consent is required, and the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
Claims
1. A method for generating a target page code, characterized in that: include: Get the target page; Parsing the target page to obtain location information of the container element on the target page; Determining a container layout type of the target page based on the position information of the container element, wherein the container layout type is a layout type between each container element; Determine, based on the container layout type of the target page, a container layout template code that matches the container layout type of the target page; Generate target page code based on the container layout template code.
2. The method for generating a target page code according to claim 1, characterized in that: The determining the container layout type of the target page based on the position information of the container element includes: Determine any two container elements in the target page as a container element group to obtain at least one container element group; Determine the container layout type of the container element group based on the position information of two container elements in the container element group, and obtain the container layout type of each container element group; The container layout type of the target page is determined based on the container layout types of each of the container component groups.
3. The method for generating a target page code according to claim 2, characterized in that: The layout type is a horizontal layout type, a vertical layout type or a row-column layout type, and determining the container layout type of the target page based on the container layout type of each of the container element groups includes: If the container layout types of all the container element groups are horizontal layout types, determining that the container layout type of the target page is a horizontal layout type; If the container layout types of all the container component groups are vertical layout types, determining that the container layout type of the target page is a vertical layout type; If the container layout types of the container component groups are neither the horizontal layout type nor the vertical layout type, it is determined that the container layout type of the target page is the row-column layout type.
4. The method for generating a target page code according to claim 2, characterized in that: The step of determining the container layout type of the container component group based on the position information of two container components in the container component group to obtain the container layout type of each container component group includes: Determine, according to the position information of the two container elements, a container transverse distance difference in the transverse direction of the two container elements and a container longitudinal distance difference in the longitudinal direction of the two container elements, wherein the container transverse distance difference is a distance difference between the left borders of the two container elements; and the container longitudinal distance difference is a distance difference between the upper borders of the two container elements; If the container transverse distance difference is less than a first preset value, the container layout type of the container element group is determined to be a longitudinal layout type; if the container longitudinal distance difference is less than a second preset value, the container layout type of the container element group is determined to be a transverse layout type; if the container transverse distance difference is not less than the first preset value, and the container longitudinal distance difference is not less than the second preset value, the container layout type of the container element group is determined to be a row-column layout type.
5. The method for generating a target page code according to claim 1, characterized in that: The generating the target page code based on the container layout template code includes: Obtaining a container template code of the container element; The container template code of the container element is added to the container layout template code to obtain the target page code.
6. The method for generating a target page code according to claim 5, characterized in that: The obtaining of the container template code of the container element comprises: Acquire location information of atomic elements obtained when parsing the target page, wherein each of the atomic elements is located in one of the container elements; Determining an atomic component set of the container component based on the position information of the container component and the position information of the atomic component, wherein each atomic component in the atomic component set of the container component is located in the container component; Determine the atomic layout type of the container element based on the position information of the atomic element in the atomic element set of the container element, the atomic layout type being the layout type between the atomic elements; Determine the atomic layout template code of the container element based on the atomic layout type of the container element; The container template code of the container element is determined based on the atomic layout template code of the container element to obtain the container template code of the container element.
7. The method for generating a target page code according to claim 6, characterized in that: The step of determining the container template code of the container element based on the atomic layout template code of the container element to obtain the container template code of the container element comprises: Obtaining the atomic template code of the atomic element; Adding the atomic template code of the atomic element in the atomic element set of the container element to the atomic layout template code of the container element to obtain the added layout template code of the container element; The added layout template code of the container element is added to the container blank template code of the container element to obtain the container template code of the container element.
8. The method for generating a target page code according to claim 7, characterized in that: The obtaining of the atomic template code of the atomic element comprises: Obtaining text information in the atomic element; Determining component attribute information of the atomic component based on text information in the atomic component, wherein the component attribute information is used to set a display mode of the atomic component; Obtaining an atomic blank template code of the atomic element; The text information and component attribute information in the atomic component are added to the atomic blank template code of the atomic component to obtain the atomic template code of the atomic component.
9. A device for generating a target page code, characterized in that: include: Page acquisition module, used to acquire the target page; A page parsing module, used to parse the target page to obtain location information of the container element on the target page; A layout determination module, configured to determine a container layout type of the target page based on the position information of the container element, wherein the container layout type is a layout type between various container elements; A template determination module, configured to determine, based on the container layout type of the target page, a container layout template code that matches the container layout type of the target page; A code generation module is used to generate target page code based on the container layout template code.
10. An electronic device, characterized in that: The invention comprises a memory and a processor, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to execute the steps in the method for generating a target page code according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the method for generating a target page code according to any one of claims 1 to 8.
12. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps in the method for generating a target page code according to any one of claims 1 to 8 are implemented.
