Method and system for realizing hotel price monitoring based on browser plug-in, and medium
Through the hotel price monitoring method based on browser plug-in, the problems of low automation and low efficiency in the existing technology are solved, automated monitoring and real-time price abnormality judgment are realized, and the accuracy and efficiency of monitoring are improved.
Patent Information
- Application Number
- CN202411887881.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-03-28
AI Technical Summary
The existing hotel price monitoring technology has low degree of automation and low efficiency, which leads to cumbersome manual operations, prone to price record deviations, and the inability to monitor price abnormalities in real time.
Using a browser plug-in-based method, the configuration file is generated by setting monitoring information, the hotel room type information is automatically obtained and parsed, the price fluctuations are compared, the price abnormality is judged, and the evidence is automatically generated by screenshots.
It improves the automation and efficiency of hotel price monitoring, reduces manual errors, enhances the accuracy and real-timeness of monitoring, and reduces labor costs.
Smart Images

Figure CN119718470A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, system and medium for realizing hotel price monitoring based on a browser plug-in. Background Art
[0002] During the peak tourist season, hotel prices fluctuate significantly. This imbalance in supply and demand may lead to price increases that are beyond the tolerance of consumers, causing dissatisfaction with the hotel industry. It is particularly important to monitor hotel prices and promptly detect and intervene in unfair practices such as price fraud and price gouging.
[0003] However, existing hotel price monitoring technology has obvious shortcomings. Monitors need to manually visit the hotel website, record the price of each room type, and compare it with the historical price. This process is not only time-consuming and labor-intensive, but also may cause deviations in the recorded prices due to human factors. In addition, when prices fluctuate abnormally, it is necessary to take screenshots of the webpage and save them for subsequent evidence storage. These manual operations are not only inefficient, but also increase processing costs.
[0004] Therefore, the existing technology has the problems of low automation and low efficiency. Summary of the invention
[0005] The purpose of the present invention is to propose a method, system and medium for hotel price monitoring based on a browser plug-in, aiming to solve the technical problems of low automation and low efficiency in the prior art.
[0006] To achieve the above object, the present invention provides a method for monitoring hotel prices based on a browser plug-in, which comprises the following steps:
[0007] S10, setting monitoring information to generate a configuration file, the monitoring information at least including the name of the hotel booking platform to be monitored, the hotel ID, the room type and the monitoring date;
[0008] S20, obtaining a base price and a price fluctuation standard of at least one room type of the hotel;
[0009] S30, starting a browser plug-in, generating an access link according to the monitoring information, and accessing the link through a browser;
[0010] S40, obtaining and parsing hotel room type information on the webpage to obtain parsing results, including at least one room type and its current price;
[0011] S50, comparing the current price with the benchmark price of the same room type, and judging whether the hotel price is abnormal according to the price fluctuation standard; if so, executing S60, if not, executing S70;
[0012] S60, capturing screens in sequence according to the size of the interface, and generating the original web page image by stitching;
[0013] S70, repeat S30-S50 until all tasks to be monitored in the configuration file are completed.
[0014] Optionally, in S20, the price of any room type corresponding to any specified date is obtained as the base price of the room type or a preset base price; the price fluctuation standard is specifically a preset increase ratio and decrease ratio.
[0015] Optionally, in S50, it is determined whether the hotel price is abnormal according to the price fluctuation standard, specifically, whether the hotel price fluctuation is greater than the increase ratio or less than the decrease ratio.
[0016] Optionally, S40 specifically injects code into the page by using JavaScript injection before the webpage starts loading, intercepts the ajax request, and obtains the hotel room information; and converts the obtained text data into json format, and then parses it to obtain the parsing result.
[0017] Optionally, S30 includes at least the following steps:
[0018] S31, start the browser plug-in and wait for user instructions;
[0019] S32, receiving user instructions, creating an XMLHttpRequest object for sending a network request;
[0020] S33, initiating a GET request to a specified server address, specifically an access link generated according to the monitoring information;
[0021] S34, setting a listener to monitor the state change of the network request; when the network request is responded to, the listener is triggered;
[0022] S35. Execute different operations according to the response status code.
[0023] Optionally, the method further includes: S80, generating a table according to the completion status of the monitoring task.
[0024] Optionally, S60 at least includes the following steps:
[0025] S61, initializing a canvas for storing a screenshot of the entire web page;
[0026] S62, determining the width and height of the entire webpage to determine the size of the canvas;
[0027] S63, determining the width and height of the browser window, which are used to calculate the number of required interceptions;
[0028] S64, calculating the number of times the web page needs to be intercepted in the horizontal direction and the vertical direction by comparing the web page size and the browser window size;
[0029] S65, using a recursive function to scroll the web page section by section and capture an image of each section;
[0030] S66, copying each captured image to a corresponding position on the canvas, and splicing them to generate the original web page image.
[0031] Optionally, S60 further includes: S67, converting the stitched canvas content into a link format, allowing the user to download the web page screenshot by clicking the link.
[0032] Corresponding to the method for implementing hotel price monitoring based on a browser plug-in, the present invention provides a system for implementing hotel price monitoring based on a browser plug-in, which comprises:
[0033] A setting module, used to set monitoring information to generate a configuration file, wherein the monitoring information at least includes the name of the hotel booking platform to be monitored, the hotel ID, the room type and the monitoring date;
[0034] An information acquisition module, used to obtain a base price and a price fluctuation standard of at least one room type of a hotel;
[0035] The monitoring module is used to start the browser plug-in, generate an access link according to the monitoring information, and access the link through the browser; obtain and parse the hotel room type information in the web page, and obtain the parsing result, which includes at least one room type and its current price;
[0036] The judgment module is used to compare the current price with the benchmark price of the same room type, and judge whether the hotel price is abnormal according to the price fluctuation standard; if so, the screen is captured in sequence according to the interface size, and the original web page image is generated by splicing; if not, the monitoring step and the judgment step are repeated until all the tasks to be monitored in the configuration file are completed;
[0037] The web page image generation module is used to capture the screen in sequence according to the interface size and generate the original web page image by splicing.
[0038] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which is stored a hotel price monitoring program based on a browser plug-in. When the hotel price monitoring program based on a browser plug-in is executed by a processor, the steps of the hotel price monitoring method based on a browser plug-in as described above are implemented.
[0039] The beneficial effects of the present invention are:
[0040] (1) Compared with the prior art, the present invention is based on a browser plug-in, which solves the problems of cumbersome manual operation and low efficiency in traditional hotel price monitoring. By setting a configuration file for monitoring information, the plug-in can automatically generate access links based on the information in the configuration file, and automatically access these links through the browser. This method not only reduces errors in manual input, but also improves the accuracy and efficiency of monitoring. It can automatically obtain and parse hotel room information on the web page, and then compare it with the benchmark price to determine whether there is any abnormality in the price. If an abnormality is found, the plug-in can also automatically capture and splice web page screenshots to provide intuitive evidence for the price abnormality. The entire process does not require manual intervention, which greatly reduces labor costs and improves the real-time and reliability of monitoring.
[0041] (2) Compared with the prior art, the present invention provides a flexible price monitoring benchmark setting method by obtaining the room price on a specified date as the benchmark price, or by presetting the benchmark price; at the same time, by presetting the increase ratio and decrease ratio as the price fluctuation standard, the judgment of price anomalies is made more accurate and automated, thereby improving the flexibility and adaptability of price monitoring, and being able to quickly adjust the monitoring strategy according to different market conditions and needs.
[0042] (3) Compared with the prior art, the present invention uses JavaScript injection technology to intercept Ajax requests and can obtain dynamically loaded web page content, especially room type and price information. It overcomes the limitations of traditional static web page crawling and ensures the comprehensiveness and real-time nature of monitoring data.
[0043] (4) Compared with the prior art, the present invention realizes a complete network request and response processing flow by starting a browser plug-in, receiving user instructions, creating an XMLHttpRequest object, initializing a GET request, setting a listener, and performing operations according to the response status code. This automated request processing mechanism improves the efficiency and accuracy of data acquisition while reducing the need for manual operations.
[0044] (5) Compared with the prior art, the present invention facilitates data tracing and management by generating a table of the completion status of the monitoring tasks.
[0045] (6) Compared with the prior art, the present invention realizes a complete screenshot of the entire web page by initializing the canvas, calculating the number of interceptions, recursively intercepting images and splicing them, ensuring that the web page information can be fully recorded during the monitoring process, providing convenience for subsequent analysis and evidence storage, and enhancing the persuasiveness of the monitoring results.
[0046] (7) Compared with the prior art, the present invention forms a complete hotel price monitoring system by means of setting modules, information acquisition modules, monitoring modules, judgment modules and web page image generation modules, which integrates various links of the monitoring process, improves the organization and systematicness of the monitoring work, facilitates management and maintenance, and also improves the efficiency and accuracy of monitoring.
[0047] These and other aspects of the present application will be more concise and understandable in the following description of the embodiments. It should be understood that the above general description and the following detailed description are only exemplary and explanatory and cannot limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.
[0049] In the figure:
[0050] Figure 1 The present invention is a flowchart of an embodiment of a method for monitoring hotel prices based on a browser plug-in.
[0051] Figure 2 This is a framework diagram of an embodiment of a hotel price monitoring system implemented based on a browser plug-in according to the present invention. DETAILED DESCRIPTION
[0052] Below, the present application is further described in conjunction with the accompanying drawings and specific implementation methods. It should be noted that, under the premise of no conflict, the various embodiments or technical features described below can be arbitrarily combined to form a new embodiment.
[0053] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in combination with specific embodiments and with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are intended to distinguish two non-identical entities or non-identical parameters with the same name. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, other steps or units inherent to a process, method, system, product or device that includes a series of steps or units.
[0055] 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.
[0056] 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.
[0057] 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.
[0058] See also Figure 1 As shown, a method for monitoring hotel prices based on a browser plug-in provided by an embodiment of the present invention includes the following steps:
[0059] S10, setting monitoring information to generate a configuration file, the monitoring information at least including the name of the hotel booking platform to be monitored, the hotel ID, the room type and the monitoring date;
[0060] S20, obtaining a base price and a price fluctuation standard of at least one room type of the hotel;
[0061] S30, starting a browser plug-in, generating an access link according to the monitoring information, and accessing the link through a browser;
[0062] S40, obtaining and parsing hotel room type information on the webpage to obtain parsing results, including at least one room type and its current price;
[0063] S50, comparing the current price with the benchmark price of the same room type, and judging whether the hotel price is abnormal according to the price fluctuation standard; if so, executing S60, if not, executing S70;
[0064] S60, capturing screens in sequence according to the size of the interface, and generating the original web page image by stitching;
[0065] S70, repeat S30-S50 until all tasks to be monitored in the configuration file are completed.
[0066] The present invention is based on a browser plug-in, which solves the problems of cumbersome manual operation and low efficiency in traditional hotel price monitoring; by setting a configuration file generated by monitoring information, the plug-in can automatically generate access links according to the information in the configuration file, and automatically access these links through the browser, which not only reduces the errors of manual input, but also improves the accuracy and efficiency of monitoring; it can automatically obtain and parse the hotel room type information in the web page, and then compare it with the benchmark price to determine whether there is an abnormality in the price; if an abnormality is found, the plug-in can also automatically capture and splice web page screenshots to provide intuitive evidence for the price abnormality, and the whole process does not require manual intervention, which greatly reduces the labor cost and improves the real-time and reliability of monitoring.
[0067] In this embodiment, in S20, the price of any room type corresponding to any specified date is obtained as the base price of the room type or a preset base price; the price fluctuation standard is specifically a preset increase ratio and decrease ratio.
[0068] The present invention provides a flexible price monitoring benchmark setting method by obtaining the room price on a specified date as a benchmark price, or by presetting a benchmark price; at the same time, by presetting an increase ratio and a decrease ratio as a price fluctuation standard, the judgment of price anomalies is made more accurate and automated, thereby improving the flexibility and adaptability of price monitoring, and being able to quickly adjust the monitoring strategy according to different market conditions and needs.
[0069] In this embodiment, in S50, it is determined whether the hotel price is abnormal according to the price fluctuation standard, specifically, whether the hotel price fluctuation is greater than the increase ratio or less than the decrease ratio.
[0070] In this embodiment, S40 specifically uses JavaScript injection to inject code into the page before the webpage starts loading, intercepts the ajax request, and obtains the hotel room information; and converts the obtained text data into json format, and then parses it to obtain the parsing result.
[0071] The present invention uses JavaScript injection technology to intercept Ajax requests, and can obtain dynamically loaded web page content, especially room type and price information, thus overcoming the limitations of traditional static web page crawling and ensuring the comprehensiveness and real-time nature of monitoring data.
[0072] In this embodiment, S30 at least includes the following steps:
[0073] S31, start the browser plug-in and wait for user instructions;
[0074] S32, receiving user instructions, creating an XMLHttpRequest object for sending a network request;
[0075] S33, initiating a GET request to a specified server address, specifically an access link generated according to the monitoring information;
[0076] S34, setting a listener to monitor the state change of the network request; when the network request is responded to, the listener is triggered;
[0077] S35. Execute different operations according to the response status code.
[0078] The present invention realizes a complete network request and response processing flow by starting a browser plug-in, receiving user instructions, creating an XMLHttpRequest object, initializing a GET request, setting a listener, and performing operations according to a response status code. This automated request processing mechanism improves the efficiency and accuracy of data acquisition and reduces the need for manual operations.
[0079] Preferably, if it is the first status code, it means that the request is successful and the plug-in will process the data returned by the server; if it is the second status code or other error code, it means that the plug-in will process the error and display the error information to the user.
[0080] The present invention clarifies the processing mechanism of request success and failure, ensuring that various situations can be handled in a timely manner during the monitoring process; processing data when successful and displaying error information when failed, this mechanism improves the stability of the system and user experience, and ensures the continuity and reliability of the monitoring task.
[0081] In this embodiment, the method further includes: S80, generating a table according to the completion status of the monitoring task to facilitate data tracing and management.
[0082] In this embodiment, S60 at least includes the following steps:
[0083] S61, initializing a canvas for storing a screenshot of the entire web page;
[0084] S62, determining the width and height of the entire webpage to determine the size of the canvas;
[0085] S63, determining the width and height of the browser window, which are used to calculate the number of required interceptions;
[0086] S64, calculating the number of times the web page needs to be intercepted in the horizontal direction and the vertical direction by comparing the web page size and the browser window size;
[0087] S65, using a recursive function to scroll the web page section by section and capture an image of each section;
[0088] S66, copying each captured image to a corresponding position on the canvas, and splicing them to generate the original web page image.
[0089] The present invention realizes a complete screenshot of the entire web page by initializing the canvas, calculating the number of interceptions, recursively intercepting images and splicing them, ensuring that the web page information can be fully recorded during the monitoring process, providing convenience for subsequent analysis and evidence storage, and enhancing the persuasiveness of the monitoring results.
[0090] Preferably, S60 further includes: S67, converting the stitched canvas content into a link format, allowing the user to download the web page screenshot by clicking the link.
[0091] like Figure 2 As shown, the present invention also provides a hotel price monitoring system based on a browser plug-in, which includes:
[0092] A setting module 10 is used to set monitoring information to generate a configuration file, wherein the monitoring information at least includes the name of the hotel booking platform to be monitored, the hotel ID, the room type and the monitoring date;
[0093] An information acquisition module 20 is used to acquire a base price and a price fluctuation standard of at least one room type of a hotel;
[0094] Monitoring module 30, used to start the browser plug-in, generate an access link according to the monitoring information and access the link through the browser; obtain and parse the hotel room type information in the web page to obtain the parsing result, which includes at least one room type and its current price;
[0095] The judgment module 40 is used to compare the current price with the benchmark price of the same room type, and judge whether the hotel price is abnormal according to the price fluctuation standard; if so, the screens are captured in sequence according to the interface size, and the original web page image is generated by splicing; if not, the monitoring step and the judgment step are repeated until all the tasks to be monitored in the configuration file are completed;
[0096] The web page image generation module 50 is used to capture the screen in sequence according to the interface size and generate the original web page image by splicing.
[0097] The present invention forms a complete hotel price monitoring system by setting up a module 10, an information acquisition module 20, a monitoring module 30, a judgment module 40 and a web page image generation module 50, which integrates various links of the monitoring process, improves the organization and systematicness of the monitoring work, facilitates management and maintenance, and also improves the efficiency and accuracy of monitoring.
[0098] The embodiment of the present invention further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the memory in the above embodiment; or a computer-readable storage medium that exists independently and is not installed in a device. The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement Figure 1 The hotel price monitoring method shown is implemented based on a browser plug-in. The computer-readable storage medium may be a read-only memory, a disk or an optical disk, etc.
[0099] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system embodiment and the storage medium embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0100] Furthermore, in this document, the terms "comprises," "comprising," or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device that includes the element.
[0101] The above description shows and describes the preferred embodiments of the present invention. It should be understood that the present invention is not limited to the form disclosed herein, and should not be regarded as excluding other embodiments, but can be used in various other combinations, modifications and environments, and can be modified within the scope of the invention, through the above teachings or the technology or knowledge of the relevant field. The changes and modifications made by those skilled in the art shall not depart from the spirit and scope of the present invention, and shall be within the scope of protection of the claims attached to the present invention.
Claims
1. A method for monitoring hotel prices based on a browser plug-in, characterized in that: The following steps are involved: S10, setting monitoring information to generate a configuration file, the monitoring information at least including the name of the hotel booking platform to be monitored, the hotel ID, the room type and the monitoring date; S20, obtaining a base price and a price fluctuation standard of at least one room type of the hotel; S30, starting a browser plug-in, generating an access link according to the monitoring information, and accessing the link through a browser; S40, obtaining and parsing hotel room type information on the webpage to obtain parsing results, including at least one room type and its current price; S50, comparing the current price with the benchmark price of the same room type, and judging whether the hotel price is abnormal according to the price fluctuation standard; If yes, execute S60, if no, execute S70; S60, capturing screens in sequence according to the size of the interface, and generating the original web page image by stitching; S70, repeat S30-S50 until all tasks to be monitored in the configuration file are completed.
2. The method for monitoring hotel prices based on a browser plug-in according to claim 1, wherein: In S20, the price of any room type corresponding to any specified date is obtained as the base price of the room type or a preset base price; the price fluctuation standard is specifically a preset increase ratio and decrease ratio.
3. The method for monitoring hotel prices based on a browser plug-in according to claim 2, wherein: In S50, it is determined whether the hotel price is abnormal according to the price fluctuation standard, specifically, whether the hotel price fluctuation is greater than the increase ratio or less than the decrease ratio.
4. The method for monitoring hotel prices based on a browser plug-in according to claim 1, wherein: S40 specifically uses JavaScript injection to inject code into the page before the webpage starts loading, intercepts the ajax request, and obtains the hotel room information; and converts the obtained text data into json format, and then parses it to obtain the parsing result.
5. The method for monitoring hotel prices based on a browser plug-in according to claim 1, wherein: S30 at least includes the following steps: S31, start the browser plug-in and wait for user instructions; S32, receiving user instructions, creating an XMLHttpRequest object for sending a network request; S33, initiating a GET request to a specified server address, specifically an access link generated according to the monitoring information; S34, setting a listener to monitor the state change of the network request; when the network request is responded to, the listener is triggered; S35. Execute different operations according to the response status code.
6. The method for monitoring hotel prices based on a browser plug-in according to claim 1, wherein: Also includes: S80. Generate a table based on the completion status of the monitoring task.
7. The method for monitoring hotel prices based on a browser plug-in according to claim 1, wherein: S60 includes at least the following steps: S61, initializing a canvas for storing a screenshot of the entire web page; S62, determining the width and height of the entire webpage to determine the size of the canvas; S63, determining the width and height of the browser window, which are used to calculate the number of required interceptions; S64, calculating the number of times the web page needs to be intercepted in the horizontal direction and the vertical direction by comparing the web page size and the browser window size; S65, using a recursive function to scroll the web page section by section and capture an image of each section; S66, copying each captured image to a corresponding position on the canvas, and splicing them to generate the original web page image.
8. The method for monitoring hotel prices based on a browser plug-in according to claim 7, characterized in that: S60 also includes: S67. Convert the stitched canvas content into a link format, allowing the user to download the web page screenshot by clicking the link.
9. A hotel price monitoring system based on a browser plug-in, characterized in that: include: A setting module, used to set monitoring information to generate a configuration file, wherein the monitoring information at least includes the name of the hotel booking platform to be monitored, the hotel ID, the room type and the monitoring date; An information acquisition module, used to obtain a base price and a price fluctuation standard of at least one room type of a hotel; The monitoring module is used to start the browser plug-in, generate an access link according to the monitoring information, and access the link through the browser; obtain and parse the hotel room type information in the web page, and obtain the parsing result, which includes at least one room type and its current price; The judgment module is used to compare the current price with the benchmark price of the same room type, and judge whether the hotel price is abnormal according to the price fluctuation standard; if so, the screen is captured in sequence according to the interface size, and the original web page image is generated by splicing; if not, the monitoring step and the judgment step are repeated until all the tasks to be monitored in the configuration file are completed; The web page image generation module is used to capture the screen in sequence according to the interface size and generate the original web page image by splicing.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a hotel price monitoring and adjustment program based on a browser plug-in. When the hotel price monitoring program based on a browser plug-in is executed by a processor, the steps of the hotel price monitoring method based on a browser plug-in as described in any one of claims 1 to 8 are implemented.