Page rendering method and device, equipment and storage medium
The server-based method generates a target screenshot with consistent rendering effects by using preset data and parameters, addressing terminal device resolution dependence and ensuring clear images across various devices.
Patent Information
- Application Number
- CN202411171573.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-13
AI Technical Summary
Existing page rendering technologies rely on terminal device resolution, leading to compatibility issues and unclear images across different device versions.
A method and apparatus that utilize a server to generate a target screenshot with stable and clear rendering effects by sending preset data to a terminal device, obtaining rendering parameters, and controlling a browser to create a second target page based on these parameters, independent of the terminal device's resolution.
Ensures consistent rendering effects across different terminal devices by generating a target screenshot with stable and clear rendering, avoiding compatibility issues and improving user experience.
Smart Images

Figure CN119128305A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of page rendering, and in particular to a page rendering method, apparatus, device and storage medium. Background Art
[0002] In the computer field, the front end is mainly responsible for rendering, presenting the rendered content to the user and handling user interactions; the back end is mainly responsible for handling database interactions, business logic and providing support for the front end. Back end development is more about data processing, storage and retrieval, as well as implementing the functions and business logic of the website or application.
[0003] In related technologies, rendering is generally performed through the front end, and the resolutions of terminal devices corresponding to different front ends are generally different, resulting in terminal device resolution dependence. For example, the Hawkeye system DRS2.0 is a natural disaster risk management platform that accesses risk data of various disasters and provides risk screening and pricing support services. The Hawkeye system can display nationwide maps, geographic details, risk overviews, and risk details on the front end. Since screenshots are generally rendered through the front end, there are problems such as terminal device resolution dependence and unclear images. Summary of the invention
[0004] The main purpose of the present application is to provide a page rendering method, apparatus, device and storage medium, which fully utilize the advantages of the rich rendering effects of the terminal device, and obtain a target screenshot corresponding to the second target page with stable and clear rendering effect without relying on the resolution of the terminal device, thereby avoiding compatibility issues in rendering due to different versions of terminal devices.
[0005] In a first aspect, the present application provides a page rendering method, applied to a server, the method comprising:
[0006] In response to a data request instruction sent by a terminal device, sending preset data corresponding to the data request instruction to the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters;
[0007] In response to a screenshot operation of the terminal device on the first target page, acquiring the preset rendering parameters;
[0008] Invoking a browser to control the browser to generate a second target page according to the preset data based on the preset rendering parameters;
[0009] According to the screenshot operation of the first target page, obtaining a target screenshot corresponding to the second target page;
[0010] The target screenshot is sent to the terminal device.
[0011] In a second aspect, the present application further provides a page rendering device, comprising:
[0012] A first sending module, configured to send preset data corresponding to the data request instruction sent by the terminal device in response to the data request instruction sent by the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters;
[0013] A first acquisition module, configured to acquire the preset rendering parameters in response to a screenshot operation of the terminal device on the first target page;
[0014] A control module, used for calling a browser, controlling the browser to generate a second target page according to the preset data based on the preset rendering parameters;
[0015] A second acquisition module, configured to acquire a target screenshot corresponding to the second target page according to the screenshot operation of the first target page;
[0016] The second sending module is used to send the target screenshot to the terminal device.
[0017] In a third aspect, the present application further provides a computer device, the computer device comprising a memory and a processor;
[0018] The memory is used to store computer programs;
[0019] The processor is used to execute the computer program and implement the page rendering method as described above when executing the computer program.
[0020] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the page rendering method as described above are implemented.
[0021] The present application provides a page rendering method, apparatus, device and storage medium, which are applied to a server, and the method comprises: in response to a data request instruction sent by a terminal device, sending preset data corresponding to the data request instruction to the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters; in response to a screenshot operation of the terminal device on the first target page, obtaining the preset rendering parameters; calling a browser, controlling the browser to generate a second target page according to the preset data based on the preset rendering parameters; according to the screenshot operation of the first target page, obtaining a target screenshot corresponding to the second target page; and sending the target screenshot to the terminal device. The present application generates a first target page through a terminal device, and then generates a second target page based on preset rendering parameters and preset data for generating the first target page, and then gives a target screenshot of the second target page to the terminal device for display. Since the second target page is generated based on the preset rendering parameters and preset data for generating the first target page, the rendering effect of the second target page is the same as that of the first target page, and the advantages of the rich rendering effects of the terminal device are fully utilized. Without relying on the resolution of the terminal device, a target screenshot corresponding to the second target page with stable and clear rendering effect is obtained, thereby avoiding compatibility issues in rendering caused by different versions of terminal devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of 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 some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 A schematic diagram of a flow chart of a page rendering method provided in an embodiment of the present application;
[0024] Figure 2 A schematic diagram of the connection between the server and the terminal device provided in the embodiment of the present application;
[0025] Figure 3 A schematic diagram of the structural framework of the rendering process provided in an embodiment of the present application;
[0026] Figure 4 A schematic block diagram of a page rendering device provided in an embodiment of the present application;
[0027] Figure 5 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] 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 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 ordinary technicians in this field without creative work are within the scope of protection of this application.
[0029] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0030] The embodiments of the present application provide a page rendering method, apparatus, device and storage medium. The page rendering method can be applied to a server, which can be a separate server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0031] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0032] See also Figure 1 , Figure 1 This is a flow chart of a page rendering method provided in an embodiment of the present application. It should be noted that the page rendering method provided in an embodiment of the present application can be applied to a server.
[0033] like Figure 2 As shown, the page rendering method is applied to a server, and the server and the terminal device are connected in communication, and the target screenshot obtained by the page rendering method can be sent to the terminal device through the server. Of course, it is not limited to this and is not limited here.
[0034] In specific implementation, the terminal device includes but is not limited to: any one of a mobile phone, a tablet computer, a laptop computer, and a desktop computer; the server can be a single server or a server cluster, or a cloud server that provides cloud computing services.
[0035] like Figure 1 As shown, the page rendering method is applied to a server, and the method includes steps S101 to S105.
[0036] Step S101: In response to a data request instruction sent by a terminal device, preset data corresponding to the data request instruction is sent to the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters.
[0037] The server can receive requests from the front end and provide corresponding services or resources according to the front end's request. The server can handle functions such as data storage, business logic, database access, etc., and can respond to the front end's request and provide the data or services required by the front end.
[0038] The client is the terminal device used by the user. It communicates with the server, sends requests to the server, and receives data returned by the server to display to the user. The client can be various types of terminal devices, such as computers, mobile phones, tablets, etc.
[0039] Front-end refers to the development field of user interface and user experience, that is, the interface that users interact directly with, including the layout, style design and interactive behavior of web pages. Generally, front-end is a specific field of terminal device development, mainly including web pages and user interfaces.
[0040] After receiving the user's click operation, the terminal device sends a data request instruction corresponding to the click operation to the server. After receiving the data request instruction, the server can provide the terminal device with preset data corresponding to the data request instruction. Specifically, the server can send the preset data corresponding to the data request instruction sent by the terminal device to the terminal device through a URL (Uniform Resource Locator), or let the terminal device obtain the corresponding preset data from multiple different interfaces of the server.
[0041] The data request instruction may include map rendering level and address, etc. Preset data refers to the data to be rendered. For example, in a natural disaster management platform, the preset data may include administrative regions, terrain, weather changes, time, etc. In an insurance product sales platform, the preset data may include the category of insurance products, the sales area of insurance products, the scope of the applicable population of insurance products, etc.
[0042] The preset rendering parameters may include output size, subdivision, minimum subdivision, maximum subdivision, maximum rendering time, noise threshold, image filter, color mapping, primary engine, secondary engine, light cache, sampling size, rendering elements (v-ray reflection, v-ray highlight, v-ray denoiser), etc. It should be noted that those skilled in the art may adjust the specific information of the preset rendering parameters according to actual rendering requirements and rendering objects, and no specific limitation is made here.
[0043] Specifically, after obtaining the preset data, the terminal device can render the page based on the preset rendering parameters to generate the first target page. For example, the first target page can include a certain province or city, a plain, 8:00 to 9:00 am as the typhoon landing time, 9:00 am to 18:00 pm as heavy rain, and the first target page can display the dynamics of typhoons and heavy rains.
[0044] Step S102: In response to a screenshot operation of the terminal device on the first target page, obtaining preset rendering parameters.
[0045] For example, after the terminal device generates the first target page, the first target page can be used as a template page for the server to refer to for rendering. For example, after determining that the rendering effect of the first target page meets the preset standard, the first target page can be screenshotted.
[0046] Based on this, the embodiment of the present application needs to obtain the preset rendering parameters for generating the first target page to render the same rendering effect as the first target page. Specifically, after the terminal device performs a screenshot operation on the first target page, the preset rendering parameters corresponding to the first target page can be obtained.
[0047] Step S103 calls the browser and controls the browser to generate a second target page according to preset data based on preset rendering parameters.
[0048] The embodiment of the present application can call the browser through Selenium. It should be noted that Selenium is a tool for testing web application programs, which can be directly run in the browser, just like a real user is operating.
[0049] For example, the page rendering can be performed by controlling the browser. This rendering is performed based on the same preset rendering parameters as the rendering parameters used to generate the first target page. Therefore, the rendering effect of the generated second target page is the same as the rendering effect of the first target page. Specifically, the element layout in the second target page is the same as the element layout in the first target page, and the color layout in the second target page is also the same as the color layout in the first target page.
[0050] In an exemplary implementation, step S103 includes step S1031 and step S1032.
[0051] Step S1031, calling a browser to control the browser to determine a layout design of preset data based on preset rendering parameters.
[0052] Step S1032: Generate a second target page according to the layout design and the preset data, wherein the layout design of the preset data in the second target page is the same as the layout design of the preset data in the first target page.
[0053] For example, the present application can call a browser from multiple browsers and control the browser to determine the layout design of the preset data on the first target page based on the preset rendering parameters. The layout design may include the layout of elements and the rendering level (that is, different elements are rendered in a certain order and rules to achieve the correct occlusion relationship and the final visual effect).
[0054] Specifically, the layout design of the preset data in the first target page can be determined based on the preset rendering parameters, for example, the layout of each element, how many levels the rendering process is divided into, and the rendering effect corresponding to each level. Then, based on the preset data to be rendered, based on the same layout design as the first target page, that is, the same element layout and rendering level, the page is rendered to generate a second target page that is the same as the first target page. The rendering effect is relatively stable and does not depend on the version and resolution of the terminal device.
[0055] For example, the layout of elements in the first target page includes: the first column shows the administrative area, the second column shows the weather changes corresponding to the time point (cloudy, rainy, snowy, etc.), and the third column shows the terrain. In addition, the first target page shows the colors corresponding to the weather changes and terrain, such as the color of clouds, the color of the sun, the color of snow, the color of terrain, etc. Then the first column of the second target page also shows the administrative area, the second column also shows the weather changes corresponding to the time point, and the third column also shows the terrain, and similarly, the corresponding colors will be displayed.
[0056] Step S104: According to the screenshot operation of the first target page, a target screenshot corresponding to the second target page is obtained.
[0057] In order to ensure that the same screenshot effect as the first target page is obtained, the embodiment of the present application can obtain the screenshot operation corresponding to the first target page when the terminal device generates the first target page and performs a screenshot operation on the first target page, and obtain the target screenshot corresponding to the second target page based on the screenshot operation.
[0058] In an exemplary implementation, step S104 includes step S1041 and step S1042.
[0059] Step S1041: Determine a screenshot area according to a screenshot operation of the first target page.
[0060] Step S1042: According to the screenshot area, the screenshot area of the second target page is captured to obtain a target screenshot corresponding to the second target page.
[0061] For example, the screenshot area can be determined according to the screenshot operation of the terminal device on the first target page. The screenshot area can include the screenshot width, the screenshot height, etc. Exemplarily, the embodiment of the present application can hide the screenshot area of the first target page taken by the terminal device by a hidden element marking method to avoid being displayed on the page of the terminal device, resulting in blocking other page contents displayed by the terminal device, thereby improving the user experience.
[0062] Specifically, the hidden screenshot area can be obtained by accessing the terminal device, and then the same screenshot operation can be performed based on the screenshot area to capture the screenshot area of the second target page to obtain the target screenshot corresponding to the second target page. Since the second target page is the same as the first target page, and the screenshot area of the second target page is also the same as the screenshot area of the first target page, the rendering effect of the target screenshot corresponding to the captured second target page is the same as the rendering effect obtained by rendering the screenshot on the terminal device, and the same rendering effect can be achieved without relying on the version, resolution and performance of the terminal device.
[0063] In an exemplary embodiment, the server may include a backend service and a middleware service; the middleware service may include a browser, a browser driver, and a web page template interface rendering; the backend service is used to manage multiple browsers and call the browser driver to take a screenshot of the second target page; the backend service is communicated with the middleware service and the terminal device.
[0064] like Figure 3 As shown, the server in the embodiment of the present application may include a backend service and a middleware service, and the backend service and the terminal device are connected in communication to obtain the data request instruction sent by the terminal device, and send the corresponding preset data to the terminal device after receiving the data request instruction, or provide multiple different service interfaces so that the terminal device can obtain the required preset data from multiple different service interfaces. The backend service and the middleware service are connected in communication to manage the browser in the middleware service. For example, the browser is called from the middleware service, and the browser generates a second target page according to the preset data based on the preset rendering parameters for generating the first target page, and the browser driver is called from the middleware service to take a screenshot of the second target page to obtain the target screenshot. In the embodiment of the present application, the backend service uniformly manages the browser, and controls the browser to generate the second target page through the backend service, which combines the advantages of rich rendering effects of the terminal device, such as cascading style effects, without relying on the resolution of the terminal device. Even if the version of the terminal device is updated, it does not affect the backend service to generate the second target page through the browser, so that the rendering effect is more stable.
[0065] Step S105: Send the target screenshot to the terminal device.
[0066] In the embodiment of the present application, after the second target page is intercepted to obtain a target screenshot, the target screenshot can be sent to the terminal device, so that the target screenshot can be displayed through the terminal device.
[0067] In an exemplary implementation, step S105 includes step S1051 and step S1052.
[0068] Step S1051: Assemble the target screenshots into a risk report, which includes location information, geographic information, and disaster information.
[0069] Step S1052: Send the risk report to the terminal device.
[0070] In the embodiment of the present application, the risk report refers to a report on various natural disasters occurring in a specific area. Among them, the risk report may include location information, geographic information, disaster information, etc. For example, population density, topography, hydrological and water system distance, administrative regions, earthquakes, geology, and risk levels of hail, waterlogging, typhoons, heavy rain, blizzards, and storm surges. Taking the Hawkeye system DRS2.0 as an example, it is a natural disaster risk management platform that accesses risk data of various disasters and provides risk screening and pricing support services. For example, in the insurance field, the insurance claim pricing for property damage caused by typhoons and the insurance claim pricing for deaths caused by typhoons. The Hawkeye system can display risk reports consisting of location information, geographic information, risk overviews and risk details of natural disasters in different areas on terminal devices.
[0071] In the related art, an HTML renderer (such as HTML2CANVAS) is usually used to take screenshots of the terminal device, and then submit them to the server for assembly to generate the final risk report, which is then downloaded and displayed by the terminal device. That is, the related art generally renders and takes screenshots through the terminal device, and then assembles the risk report by the server, resulting in dependence on the resolution and performance of the terminal device, and there are also compatibility issues between different terminal devices, making it impossible to display a clear risk report.
[0072] The embodiment of the present application generates a second target page through a server, and then captures the second target page to obtain a target screenshot. In addition, the server can also assemble the target screenshots to obtain a risk report. The terminal device only needs to display the risk report. Therefore, the embodiment of the present application does not need to rely on the resolution and performance of the terminal device, and also avoids compatibility issues caused by different terminal devices, so that a clear risk report can be displayed on the terminal device, improving the quality of the risk report displayed by the Hawkeye system DRS2.0.
[0073] In an exemplary implementation, step S1051 may specifically include: generating a risk report according to the target screenshot based on a preset report template.
[0074] A report template refers to a template that presents a risk report with different rendering effects. Specifically, multiple report templates can be pre-set in the server, and rich risk reports can be generated based on the preset report templates. For example, the target screenshots in different report templates are assembled in different ways, the target screenshots in different report templates are displayed in different ways, and the page styles presented in different report templates are different.
[0075] Exemplarily, an embodiment of the present application can utilize the web page template interface rendering function in the middleware service through the back-end service in the server, apply different report templates to assemble target screenshots into different risk reports, and generate a risk report that can include any rendering effects, thereby improving the quality of the risk report.
[0076] In an exemplary implementation, step S103 includes step S301 and step S302.
[0077] Step S301: determine a target thread among multiple threads running synchronously, each thread runs a headless browser, and the target thread is in an idle state.
[0078] Step S302: calling the headless browser running in the target thread, and controlling the headless browser to generate a second target page according to preset data based on preset rendering parameters.
[0079] The browser in the embodiment of the present application may include a headless browser. It should be noted that a headless browser refers to a browser that can run in a graphical interface.
[0080] In actual applications, if only one headless browser is run for rendering, there will be performance bottlenecks and long processing time; if it is implemented asynchronously, each time rendering is performed, the headless browser is opened and closed again, which will cause resource peaks, insufficient running memory, and system instability. Based on this, the embodiment of the present application can manage multiple headless browsers by running multiple threads synchronously. Specifically, a target thread can be determined among the multiple threads running synchronously, each thread runs a headless browser, and the current running state of the target thread is idle. The headless browser running by the target thread is called, and the headless browser can be controlled to generate a second target page based on preset rendering parameters according to preset data. Since the headless browser does not have a graphical user interface, when multiple headless browsers are run synchronously, it will not take up additional screen space or consume too many system resources, thereby ensuring the efficiency of page rendering.
[0081] In an exemplary embodiment, step S301 may specifically include: if the current running state of the thread is an idle state, determining that the thread is a target thread; if the current running state of the thread is an abnormal state, terminating the task being executed by the thread and determining that the thread is a target thread; if the current running state of the thread is a normal execution state, and the normal execution state lasts for more than a preset time, terminating the task being executed by the thread and determining that the thread is a target thread.
[0082] For example, according to the current running state of each thread, the target thread whose current running state is idle can be determined to call the headless browser running on the target thread. Specifically. If the current running state of the thread is idle, that is, the headless browser running on the thread has no tasks being executed, the thread running the headless browser can be determined to be the target thread in idle state. At this time, the headless browser running on the target thread can be called to render the page; if the current running state of the thread is abnormal, that is, the headless browser running on the thread is stuck or paused during the execution of the task, the task being executed by the thread can be ended to make the thread become the target thread in idle state, so that the headless browser running on the target thread can be called. If the current running state of the thread is normal execution state, it means that the headless browser running on the thread is running normally and executing tasks, so the headless browser running on the thread cannot be called.
[0083] Exemplarily, if the current running state of the thread is a normal execution state, but the normal execution state of the thread lasts for longer than a preset time, the task executed by the headless browser running the thread can be terminated according to the actual situation, so that the thread becomes an idle target thread, and the headless browser running the target thread can be called to perform more urgent rendering tasks.
[0084] Exemplarily, when a rendering task is received and the current running states of multiple threads are all in normal execution states, a target thread that is not in an idle state can be prompted, and when there is a target thread in an idle state, the headless browser that controls the target thread to run performs rendering processing in sequence according to the time sequence of receiving the rendering tasks.
[0085] The page rendering method provided in the above embodiment includes: in response to a data request instruction sent by a terminal device, sending preset data corresponding to the data request instruction to the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters; in response to a screenshot operation of the terminal device on the first target page, obtaining preset rendering parameters; calling a browser, controlling the browser to generate a second target page according to preset data based on preset rendering parameters; according to the screenshot operation of the first target page, obtaining a target screenshot corresponding to the second target page; and sending the target screenshot to the terminal device. The present application generates a first target page by a terminal device, and then generates a second target page based on the preset rendering parameters and preset data for generating the first target page, and then gives the target screenshot of the second target page to the terminal device for display. Since the second target page is generated based on the preset rendering parameters and preset data for generating the first target page, the rendering effect of the second target page is the same as that of the first target page, making full use of the advantages of the rich rendering effects of the terminal device, and obtaining a target screenshot corresponding to the second target page with a stable and clear rendering effect without relying on the resolution of the terminal device, thereby avoiding the compatibility problem of rendering caused by different versions of the terminal device.
[0086] See also Figure 4 , Figure 4 1 is a schematic block diagram of a page rendering device provided in an embodiment of the present application. The page rendering device can be configured in a server or an electronic device to execute the aforementioned page rendering method.
[0087] like Figure 4 As shown, the page rendering device includes: a first sending module 110 , a first obtaining module 120 , a control module 130 , a second obtaining module 140 and a second sending module 150 .
[0088] The first sending module 110 is used to send preset data corresponding to the data request instruction to the terminal device in response to the data request instruction sent by the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters.
[0089] The first acquisition module 120 is used to acquire preset rendering parameters in response to a screenshot operation of the terminal device on the first target page.
[0090] The control module 130 is used to call the browser and control the browser to generate a second target page according to preset data based on preset rendering parameters.
[0091] The second acquisition module 140 is used to acquire a target screenshot corresponding to the second target page according to the screenshot operation of the first target page.
[0092] The second sending module 150 is used to send the target screenshot to the terminal device.
[0093] In an exemplary embodiment, the control module 130 includes a design determination submodule and a generation submodule.
[0094] The design determination submodule is used to call the browser and control the browser to determine the layout design of the preset data based on the preset rendering parameters.
[0095] The generating submodule is used to generate a second target page according to the typesetting design and the preset data, wherein the typesetting design of the preset data in the second target page is the same as the typesetting design of the preset data in the first target page.
[0096] In an exemplary implementation, the second acquisition module 140 includes a region determination submodule and a capture submodule.
[0097] The area determination submodule is used to determine the screenshot area according to the screenshot operation of the first target page.
[0098] The capture submodule is used to capture the screenshot area of the second target page to obtain a target screenshot corresponding to the second target page.
[0099] In an exemplary embodiment, the second sending module 150 includes an assembling submodule and a sending submodule.
[0100] The assembly submodule is used to assemble the target screenshots into a risk report, which includes location information, geographic information, and disaster information.
[0101] The sending submodule is used to send the risk report to the terminal device.
[0102] In an exemplary embodiment, the assembly submodule is specifically used to generate a risk report according to the target screenshot based on a preset report template.
[0103] In an exemplary embodiment, the apparatus further includes a control module 130 including a thread determination submodule and a calling submodule.
[0104] The thread determination submodule is used to determine a target thread among multiple threads running synchronously, each thread runs a headless browser, and the target thread is in an idle state.
[0105] The calling submodule is used to call the headless browser running in the target thread, and control the headless browser to generate a second target page according to preset data based on preset rendering parameters.
[0106] In an exemplary embodiment, the thread determination submodule is specifically used to determine that the thread is a target thread if the current running state of the thread is an idle state; if the current running state of the thread is an abnormal state, terminate the task being executed by the thread and determine the thread as a target thread; if the current running state of the thread is a normal execution state, and the normal execution state lasts for more than a preset time, terminate the task being executed by the thread and determine the thread as a target thread.
[0107] It should be noted that technicians in the relevant field can clearly understand that for the convenience and simplicity of description, the specific working processes of the above-described devices and modules and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0108] The method of the present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0109] Exemplarily, the above method and apparatus may be implemented in the form of a computer program, which may be run on a computer device.
[0110] See also Figure 5 , Figure 5 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server or an electronic device.
[0111] like Figure 5 As shown, the computer device includes a processor, a memory, and a network interface connected via a system bus, wherein the memory may include a storage medium and an internal memory.
[0112] The storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute the steps of any page rendering method.
[0113] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0114] The internal memory provides an environment for the operation of the computer program in the storage medium. When the computer program is executed by the processor, the processor can execute the steps of any page rendering method.
[0115] The network interface is used for network communication, such as sending assigned tasks.
[0116] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0117] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0118] In one embodiment, the processor is used to execute a computer program and implement the following steps when executing the computer program:
[0119] In response to the data request instruction sent by the terminal device, sending preset data corresponding to the data request instruction to the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters;
[0120] In response to a screenshot operation of the terminal device on the first target page, obtaining preset rendering parameters;
[0121] Calling a browser to control the browser to generate a second target page according to preset data based on preset rendering parameters;
[0122] According to the screenshot operation of the first target page, a target screenshot corresponding to the second target page is obtained;
[0123] Send the target screenshot to the terminal device.
[0124] In an exemplary implementation, calling a browser and controlling the browser to generate a second target page according to preset data based on preset rendering parameters includes:
[0125] Calling the browser to control the browser to determine the layout design of the preset data based on the preset rendering parameters;
[0126] A second target page is generated according to the layout design and the preset data, wherein the layout design of the preset data in the second target page is the same as the layout design of the preset data in the first target page.
[0127] In an exemplary implementation, obtaining a target screenshot corresponding to a second target page according to a screenshot operation of a first target page includes:
[0128] Determine a screenshot area according to a screenshot operation of the first target page;
[0129] The screenshot area of the second target page is captured to obtain a target screenshot corresponding to the second target page.
[0130] In an exemplary embodiment, sending the target screenshot to the terminal device includes:
[0131] Assemble the target screenshots into a risk report, which includes location information, geographic information, and disaster information;
[0132] Send risk reports to terminal devices.
[0133] In an exemplary embodiment, the target screenshots are assembled into a risk report, including:
[0134] Generate risk reports based on target screenshots based on preset report templates.
[0135] In an exemplary implementation, calling a browser and controlling the browser to generate a second target page according to preset data based on preset rendering parameters includes:
[0136] Determine a target thread among multiple threads running synchronously, each thread runs a headless browser, and the target thread is in an idle state;
[0137] The headless browser running in the target thread is called, and the headless browser is controlled to generate a second target page according to preset data based on preset rendering parameters.
[0138] In an exemplary embodiment, determining a target thread among a plurality of threads running synchronously includes:
[0139] If the current running state of the thread is an idle state, the thread is determined to be a target thread;
[0140] If the current running state of the thread is an abnormal state, the task being executed by the thread is terminated, and the thread is determined to be the target thread;
[0141] If the current running state of the thread is a normal execution state, and the duration of the normal execution state exceeds a preset time, the task being executed by the thread is terminated, and the thread is determined to be a target thread.
[0142] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the page rendering described above can refer to the corresponding process in the embodiment of the aforementioned page rendering method, and will not be repeated here.
[0143] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. The method implemented when the computer program is executed by a processor can refer to the various embodiments of the page rendering method of the present application.
[0144] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.
[0145] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0146] It should also be understood that the term "and / or" used in the specification of this application and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system including the element.
[0147] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. The above description is only a specific implementation mode of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A page rendering method, characterized in that: Applied to the server, the methods include: In response to a data request instruction sent by a terminal device, sending preset data corresponding to the data request instruction to the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters; In response to a screenshot operation of the terminal device on the first target page, acquiring the preset rendering parameters; Invoking a browser to control the browser to generate a second target page according to the preset data based on the preset rendering parameters; According to the screenshot operation of the first target page, obtaining a target screenshot corresponding to the second target page; The target screenshot is sent to the terminal device.
2. The page rendering method according to claim 1, characterized in that: The calling of the browser to control the browser to generate a second target page according to the preset data based on the preset rendering parameters includes: Invoking a browser to control the browser to determine a layout design of the preset data based on the preset rendering parameters; A second target page is generated according to the layout design and the preset data, wherein the layout design of the preset data in the second target page is the same as the layout design of the preset data in the first target page.
3. The page rendering method according to claim 1, characterized in that: The acquiring, according to the screenshot operation of the first target page, a target screenshot corresponding to the second target page, includes: Determining a screenshot area according to the screenshot operation of the first target page; The screenshot area of the second target page is captured to obtain a target screenshot corresponding to the second target page.
4. The page rendering method according to any one of claims 1 to 3, characterized in that: The sending the target screenshot to the terminal device includes: Assembling the target screenshots into a risk report, wherein the risk report includes location information, geographic information, and disaster information; The risk report is sent to the terminal device.
5. The page rendering method according to claim 4, characterized in that: The step of assembling the target screenshots into a risk report includes: Based on a preset report template, a risk report is generated according to the target screenshot.
6. The page rendering method according to any one of claims 1 to 3, characterized in that: The calling of the browser to control the browser to generate a second target page according to the preset data based on the preset rendering parameters includes: Determine a target thread among multiple threads running synchronously, each of the threads runs a headless browser, and the target thread is in an idle state; The headless browser running in the target thread is called, and the headless browser is controlled to generate a second target page according to the preset data based on the preset rendering parameters.
7. The page rendering method according to claim 6, characterized in that: Determining the target thread among the multiple threads running synchronously includes: If the current running state of the thread is an idle state, determining the thread to be a target thread; If the current running state of the thread is an abnormal state, the task being executed by the thread is terminated, and the thread is determined to be a target thread; If the current running state of the thread is a normal execution state, and the duration of the normal execution state exceeds a preset time, the task being executed by the thread is terminated, and the thread is determined to be a target thread.
8. A page rendering device, characterized in that: include: A first sending module, configured to send preset data corresponding to the data request instruction sent by the terminal device in response to the data request instruction sent by the terminal device, so that the terminal device generates a first target page according to the preset data based on preset rendering parameters; A first acquisition module, configured to acquire the preset rendering parameters in response to a screenshot operation of the terminal device on the first target page; A control module, used for calling a browser, controlling the browser to generate a second target page according to the preset data based on the preset rendering parameters; A second acquisition module, configured to acquire a target screenshot corresponding to the second target page according to the screenshot operation of the first target page; The second sending module is used to send the target screenshot to the terminal device.
9. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is used to execute the computer program and implement the page rendering method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the page rendering method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and equipment for generating webpage screenshot
CN111382386A
Picture generation method, picture generation device and storage medium
CN117289845A
Image generation method and device, equipment and storage medium
CN117407107A
