LLM-based waterfall flow list item processing method, apparatus and device, and medium

By generating selectors, sorting, and hashing identifiers, the consistency and accuracy issues of LLM in waterfall list item processing are resolved, ensuring the stability and efficiency of the processing results.

CN121834029APending Publication Date: 2026-04-10FUJIAN ZIXUN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-07
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing LLMs struggle to guarantee consistency in processing waterfall list items, leading to missed or duplicate processing, and may also result in inaccurate processing due to token limitations and lack of focus.

Method used

The list item selector is generated by calling LLM, sorted based on the distance of each list item from the top of the browser, and identified by hash value. The selected item is then highlighted and captured by scrolling to the visible area and processed by LLM.

Benefits of technology

It achieves accurate identification and positioning of waterfall list items, ensuring consistency and accuracy in processing, avoiding omissions, adapting to complex web page structures, and improving processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121834029A_ABST
    Figure CN121834029A_ABST
Patent Text Reader

Abstract

The invention provides a method, a device and equipment for processing a waterfall flow list item based on LLM, and a medium. The method comprises the following steps: calling LLM identification and generating a list item selector; according to the DOM data of all the list items obtained by the list item selector, sorting each list item based on the distance between each list item and the top of the browser; obtaining corresponding list item data based on the sorted sequence, rolling the list item to a visual area, performing screenshot after highlight setting, and inputting the corresponding list item data, screenshot and setting processing prompt words into LLM for setting processing; and the waterfall flow list item is ensured not to be missed in processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of large language model technology, and in particular to a method, apparatus, device and medium for processing waterfall list items based on LLM. Background Technology

[0002] When mainstream LLM processes the same webpage content multiple times, the existence of LLM illusion often makes it impossible to accurately guarantee consistent results each time. In particular, as the number of processing steps increases, the illusion accumulates, leading to increasingly inaccurate results and more unexpected situations.

[0003] When using LLM for waterfall list data scraping, LLM is more prone to processing list items out of order, confusing list items with similar content, and ultimately causing omissions or duplicate processing. At the same time, a large amount of list item data may exceed token limits, or cause inattention and hallucinations. Therefore, if existing solutions are used, the accuracy of list item data and index order when scraping the same URL page multiple times using LLM cannot be guaranteed. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a method, apparatus, device and medium for processing waterfall list items based on LLM, so as to ensure that no waterfall list items are missed in processing.

[0005] In a first aspect, the present invention provides a method for processing waterfall list items based on LLM, comprising the following steps: Step S1: Call LLM to identify and generate list item selectors; Step S2: Obtain the DOM data of all list items based on the list item selector, and sort each list item based on its distance from the top of the browser window. Step S3: Obtain the corresponding list item data based on the sorted sequence, scroll the list item to the visible area, highlight it, take a screenshot, and input the corresponding list item data, screenshot, and setting processing prompts into LLM for setting processing.

[0006] Secondly, the present invention provides an apparatus for processing waterfall list items based on LLM, comprising: The selector module is used to call LLM to identify and generate list item selectors. The sorting and numbering module retrieves the DOM data of all list items based on the list item selector, and sorts each list item based on its distance from the top of the browser window. The list item processing module retrieves the corresponding list item data based on the sorted sequence, scrolls the list item to the visible area, highlights it, takes a screenshot, and inputs the corresponding list item data, screenshot, and processing prompts into the LLM for further processing.

[0007] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in the first aspect.

[0008] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.

[0009] One or more technical solutions provided by this invention have at least the following technical effects or advantages: This invention enables LLM to effectively process waterfall list items, avoiding the increased difficulty and token consumption caused by changes in the DOM structure of waterfall list items in traditional LLM recognition. Furthermore, this invention adheres to the DOM structure and spatial location, ensuring that the indexing of waterfall list items is performed according to human vision, guaranteeing a consistent user experience and preventing failure due to changes in the DOM structure. Moreover, because every list item in the waterfall list is processed, no item is missed.

[0010] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0011] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0012] Figure 1 This is a flowchart of the method in Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the device in Embodiment 2 of the present invention. Detailed Implementation

[0013] The overall concept of the technical solution in this application is as follows: Step 1: Call LLM to identify and generate a list item selector, denoted as list item selector A; Step 2: Retrieve all list items based on list item selector A. Inject a script via CDP to generate a unique hash value for each list item based on its own text content, and add it to the corresponding list item with the attribute data-ba-uuid. Simultaneously, sort the list items based on their distance from the top of the document. Core code: def generate_content_hash(self, content: str) -> str: """Generate a unique hash identifier based on the content""" try: if not content or not isinstance(content, str): raise ValueError(f'Invalid content for hash generation: {repr(content)}') import re cleaned_content = re.sub(r'\s+', ' ', content.strip()) if not cleaned_content: raise ValueError('Content is empty after cleaning') hash_obj = hashlib.md5(cleaned_content.encode('utf-8')) return hash_obj.hexdigest()[:8] except Exception as e: raise Exception(f'Content hash generation failed: {str(e)}') frome async def get_items_with_document_top(self, items: List) -> List[Dict]: """Gets the distance of an element relative to the top of the document""" items_info = [] js_code = """ (items) => { return items.map((item, index) => { try { const rect = item.getBoundingClientRect(); const content = item.textContent || item.innerText || ''; const documentTop = rect.top + window.pageYOffset; let containerScrollTop = 0; let currentElement = item.parentElement; / / Upward search for the scrollable container while (currentElement && currentElement!== document.body) { const style = window.getComputedStyle(currentElement); if (style.overflow === 'auto' || style.overflow ==='scroll' || style.overflowY === 'auto' || style.overflowY ==='scroll') { containerScrollTop += currentElement.scrollTop; break; } currentElement = currentElement.parentElement; } const finalDocumentTop = documentTop + containerScrollTop; return { index: index, documentTop: finalDocumentTop, content: content.trim() }; } catch (e) { return { index: index, documentTop: 999999 + index, / / The failed ones are placed at the end content: '' }; } }); } """ try: positions_data = await self.page.evaluate(js_code, items) for i, data in enumerate(positions_data): items_info.append({'element': items[i], 'document_top': data['documentTop'], 'content': data['content']}) except Exception as e: print(e) return items_info async def batch_inject_hash_attributes(self, items: List, hash_list:List[str]) -> None: """Batch inject hash attributes into DOM elements""" try: js_code = """ ([items, hashList]) => { let injectedCount = 0; items.forEach((item, index) => { if (index < hashList.length && item && typeof item.setAttribute === 'function') { try { item.setAttribute('data-ba-uuid', hashList[index]); injectedCount++; } catch (e) { console.warn('Failed to inject hash for item', index, e); } } }); return injectedCount; } """ injected_count = await self.page.evaluate(js_code, [items, hash_list]) print(injected_count) except Exception as e: print(e) Step 3: Based on the sorted list items, process them sequentially according to their order. During processing, the current list item needs to be scrolled into the visible area, highlighted, and captured as a screenshot, which is then processed by the LLM.

[0014] The advantages of the above steps: 1. Precise list item identification and positioning LLM-assisted selector generation: Step 1 uses LLM to identify list items and generate selectors (selector A). Compared with traditional manual writing or rule matching, it can more flexibly deal with complex web page structures (such as dynamically generated lists and irregular layouts) and improve the accuracy of list item identification.

[0015] Precise position calculation: In step 2, the get_items_with_document_top method not only calculates the distance of the element relative to the top of the document, but also takes into account the influence of nested scrolling containers (by looking up at the scrollable parent element and accumulating the scroll distance), ensuring that accurate position information can still be obtained in complex scrolling scenarios (such as lists in pop-ups and multi-layered nested scrolling areas), providing a reliable basis for subsequent sorting and scrolling.

[0016] 2. Uniqueness and Traceability of Content Content-based hashing: A unique hash is generated for the text content of each list item using `generate_content_hash`, and injected into the DOM as the `data-ba-uuid` attribute (`batch_inject_hash_attributes` in step 2), achieving a strong binding between content and element. Even if the position of the list item changes or the DOM structure is updated, the hash value remains unchanged as long as the content remains the same, which can be used for subsequent element tracking, deduplication, or association with data (such as historical processing records).

[0017] Robustness of hash generation: The content cleaning steps (removing extra whitespace and trimming the beginning and end) avoid generating different hashes for the same content due to format differences (such as line breaks and the number of spaces), ensuring the stability of the identifier.

[0018] 3. Ordered processing and visualized reliability Position-based sorting: Step 2 sorts the elements by their distance from the top of the document, ensuring that the order in which the list items are processed is consistent with the user's visual perception of "from left to right and from top to bottom", which conforms to the logic of natural reading and avoids confusion caused by out-of-order processing.

[0019] Accuracy of visualization processing: The process of "scrolling to the visible area + highlighting + screenshotting" in step 3, combined with the previous position calculation results, can ensure that the list item being processed is fully visible in the screenshot and the highlighting effect is clear, providing clear visual input for subsequent LLM processing (such as content analysis and information extraction) and reducing processing errors caused by invisible or blurry elements.

[0020] 4. Process automation and fault tolerance End-to-end automation: From selector generation, element location, hash injection to scrolling screenshots, the entire process requires no manual intervention, making it suitable for batch processing of a large number of list items and improving efficiency.

[0021] Exception handling mechanism: During hash generation, invalid content (empty values, non-strings) is actively thrown as an error to avoid generating invalid identifiers; If the position calculation fails, the element will be placed at the end (999999 + index), without affecting the normal sorting of other elements; During hash injection, exceptions involving a single element (such as an element being removed) are captured without interrupting the overall batch operation, ensuring process stability.

[0022] 5. Flexibility and scalability Adaptable to various web page scenarios: Whether it is a list in a normal document flow, an element in a nested scrolling container, or dynamically loaded content, it can be well compatible through LLM-generated selectors and scrolling container adaptation logic.

[0023] The reusable core method consists of three core functions (hash generation, position calculation, and attribute injection), which are independent and can be reused in other scenarios that require content identification and element positioning (such as web page content annotation and element tracking). Example

[0024] like Figure 1 As shown, this embodiment provides a method for processing waterfall list items based on LLM, including the following steps: Step S1: Call LLM to identify and generate list item selectors; Step S2: Obtain the DOM data of all list items based on the list item selector, and sort each list item based on its distance from the top of the browser window. Step S3: Obtain the corresponding list item data based on the sorted sequence, scroll the list item to the visible area, highlight it, and take a screenshot. Input the corresponding list item data, screenshot, and setting the processing prompt into LLM for setting processing; repeat step S3 until each list item has been processed.

[0025] In this embodiment, preferably, step S1 specifically involves: launching a browser and navigating to the webpage containing the target list; injecting a customized webpage data extraction script into the webpage via the CDP protocol, the webpage data extraction script being used to extract webpage structure information; capturing the current webpage and obtaining screenshot characters; inputting the webpage structure information, screenshot characters, and extraction prompts into the user-specified LLM to obtain the target list item selector for the webpage.

[0026] In this embodiment, preferably, the webpage data extraction script is used to extract DOM nodes within the first two screens of the webpage; filter out nodes containing inline styles, inline scripts, images, audio, video, and links; and remove redundant spaces and comments to obtain the webpage structure information; The specific steps for extracting DOM nodes within the first two screens of a webpage are as follows: Calculate twice the current browser window height using `window.innerHeight*2` as the height threshold for the first two screens. Set top and bottom thresholds based on this height threshold, and only process DOM elements within this range. Mark elements that exceed the two-screen range. First, obtain all DOM elements in the webpage. Iterate through each element and obtain its position information in the viewport using `getBoundingClientRect`. If the top of an element is greater than the top threshold or the bottom is less than the bottom threshold, mark the element as to be removed. After marking all elements, remove the corresponding elements to obtain the DOM nodes.

[0027] In this embodiment, preferably, step S2 specifically involves: obtaining the DOM data of all list items according to the list item selector; generating a hash value for the specified content in the DOM data for each list item using generate_content_hash; binding the hash value to the corresponding element as a DOM attribute using batch_inject_hash_attributes, where the DOM attribute is the data-ba-uuid attribute; and sorting each list item based on its distance from the top of the browser window. Step S3 specifically involves: obtaining the corresponding list item data based on the sorted sequence, scrolling the list item to the visible area, highlighting it, taking a screenshot, and inputting the corresponding list item data, screenshot, and setting the processing prompt into the LLM for setting processing.

[0028] Based on the same inventive concept, this application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2. Example

[0029] like Figure 2 As shown, this embodiment provides an apparatus for processing waterfall list items based on LLM, including: The selector module is used to call LLM to identify and generate list item selectors. The sorting and numbering module retrieves the DOM data of all list items based on the list item selector, and sorts each list item based on its distance from the top of the browser window. The list item processing module retrieves the corresponding list item data based on the sorted sequence, scrolls the list item into the visible area, highlights it, takes a screenshot, and inputs the corresponding list item data, screenshot, and set processing prompts into the LLM for processing. The list item processing module is executed repeatedly until each list item has been processed.

[0030] In this embodiment, preferably, the selector acquisition module specifically comprises: launching a browser and navigating to the webpage containing the target list; injecting a customized webpage data extraction script into the webpage via the CDP protocol, the webpage data extraction script being used to extract webpage structure information; capturing the current webpage and obtaining screenshot characters; inputting the webpage structure information, screenshot characters, and extraction prompts into the user-specified LLM to obtain the target list item selector for the webpage.

[0031] In this embodiment, preferably, the webpage data extraction script is used to extract DOM nodes within the first two screens of the webpage; filter out nodes containing inline styles, inline scripts, images, audio, video, and links; and remove redundant spaces and comments to obtain the webpage structure information; The specific steps for extracting DOM nodes within the first two screens of a webpage are as follows: Calculate twice the current browser window height using `window.innerHeight*2` as the height threshold for the first two screens. Set top and bottom thresholds based on this height threshold, and only process DOM elements within this range. Mark elements that exceed the two-screen range. First, obtain all DOM elements in the webpage. Iterate through each element and obtain its position information in the viewport using `getBoundingClientRect`. If the top of an element is greater than the top threshold or the bottom is less than the bottom threshold, mark the element as to be removed. After marking all elements, remove the corresponding elements to obtain the DOM nodes.

[0032] In this embodiment, preferably, the sorting and numbering module specifically performs the following steps: First, it obtains the DOM data of all list items based on the list item selector. Then, for each list item, it first generates a hash value for the specified content in the DOM data using `generate_content_hash`. Next, it binds the hash value to the corresponding element as a DOM attribute using `batch_inject_hash_attributes`, where the DOM attribute is the `data-ba-uuid` attribute. Simultaneously, it sorts each list item based on its distance from the top of the browser window. Step S3 specifically involves: obtaining the corresponding list item data based on the sorted sequence, scrolling the list item to the visible area, highlighting it, taking a screenshot, and inputting the corresponding list item data, screenshot, and setting the processing prompt into the LLM for setting processing.

[0033] Since the apparatus described in Embodiment 2 of the present invention is an apparatus used to implement the method of Embodiment 1 of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in Embodiment 1 of the present invention, and therefore will not be described again here. All apparatuses used in the method of Embodiment 1 of the present invention fall within the scope of protection of the present invention.

[0034] Based on the same inventive concept, this application provides an electronic device embodiment corresponding to Embodiment 1, as detailed in Embodiment 3. Example

[0035] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it can implement any of the implementation methods in Embodiment 1.

[0036] Since the electronic device described in this embodiment is the device used to implement the method in Embodiment 1 of this application, those skilled in the art can understand the specific implementation method and various variations of the electronic device in this embodiment based on the method described in Embodiment 1 of this application. Therefore, how the electronic device implements the method in the embodiment of this application will not be described in detail here. Any device used by those skilled in the art to implement the method in the embodiment of this application falls within the scope of protection of this application.

[0037] Based on the same inventive concept, this application provides a storage medium corresponding to Embodiment 1, as detailed in Embodiment 4. Example

[0038] This embodiment provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it can implement any of the implementation methods in Embodiment 1.

[0039] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0040] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0041] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0042] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0043] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for processing waterfall list items based on LLM, characterized in that: Includes the following steps: Step S1: Call LLM to identify and generate list item selectors; Step S2: Obtain the DOM data of all list items based on the list item selector, and sort each list item based on its distance from the top of the browser window. Step S3: Obtain the corresponding list item data based on the sorted sequence, scroll the list item to the visible area, highlight it, take a screenshot, and input the corresponding list item data, screenshot, and setting processing prompts into LLM for setting processing.

2. The method for processing waterfall list items based on LLM according to claim 1, characterized in that: Step S1 specifically involves: launching the browser and navigating to the webpage containing the target list; injecting a customized webpage data extraction script into the webpage via the CDP protocol, wherein the webpage data extraction script is used to extract webpage structural information; Capture the current webpage and obtain the screenshot characters; Input the webpage structure information, screenshot characters, and extraction prompts into the user-specified LLM to obtain the target list item selector for the webpage.

3. The method for processing waterfall list items based on LLM according to claim 1, characterized in that: The webpage data extraction script is used to extract DOM nodes within the first two screens of the webpage; Filter out nodes containing inline styles, inline scripts, images, audio, video, and links; and remove extra spaces and comments to obtain the webpage structure information; The specific steps for extracting DOM nodes within the first two screens of the webpage are as follows: calculate twice the current browser window height using window.innerHeight*2 as the height threshold for the first two screens, set the top and bottom thresholds based on the height threshold, and then only process DOM elements within this range. Mark elements that exceed two screen widths; first, obtain all DOM elements in the webpage; traverse each element and obtain its position information in the viewport using getBoundingClientRect; if the top of an element is greater than the top threshold or the bottom is less than the bottom threshold, mark the element as to be removed; after all elements are marked, remove the corresponding elements to obtain the DOM nodes.

4. The method for processing waterfall list items based on LLM according to claim 1, characterized in that: Step S2 specifically involves: obtaining the DOM data of all list items based on the list item selector; generating a hash value for each list item using generate_content_hash to set content in the DOM data; binding the hash value to the corresponding element as a DOM attribute using batch_inject_hash_attributes, where the DOM attribute is the data-ba-uuid attribute; and sorting each list item based on its distance from the top of the browser window. Step S3 specifically involves: obtaining the corresponding list item data based on the sorted sequence, scrolling the list item to the visible area, highlighting it, taking a screenshot, and inputting the corresponding list item data, screenshot, and setting the processing prompt into the LLM for setting processing.

5. A device for processing waterfall list items based on LLM, characterized in that: include: The selector module is used to call LLM to identify and generate list item selectors. The sorting and numbering module retrieves the DOM data of all list items based on the list item selector, and sorts each list item based on its distance from the top of the browser window. The list item processing module retrieves the corresponding list item data based on the sorted sequence, scrolls the list item to the visible area, highlights it, takes a screenshot, and inputs the corresponding list item data, screenshot, and processing prompts into the LLM for further processing.

6. The apparatus for processing waterfall list items based on LLM according to claim 5, characterized in that: The selector acquisition module specifically involves: launching a browser and navigating to the webpage containing the target list; injecting a customized webpage data extraction script into the webpage via the CDP protocol, wherein the webpage data extraction script is used to extract webpage structure information; Capture the current webpage and obtain the screenshot characters; Input the webpage structure information, screenshot characters, and extraction prompts into the user-specified LLM to obtain the target list item selector for the webpage.

7. The apparatus for processing waterfall list items based on LLM according to claim 5, characterized in that: The webpage data extraction script is used to extract DOM nodes within the first two screens of the webpage; Filter out nodes containing inline styles, inline scripts, images, audio, video, and links; and remove extra spaces and comments to obtain the webpage structure information; The specific steps for extracting DOM nodes within the first two screens of the webpage are as follows: calculate twice the current browser window height using window.innerHeight*2 as the height threshold for the first two screens, set the top and bottom thresholds based on the height threshold, and then only process DOM elements within this range. Mark elements that exceed two screen widths; first, obtain all DOM elements in the webpage; traverse each element and obtain its position information in the viewport using getBoundingClientRect; if the top of an element is greater than the top threshold or the bottom is less than the bottom threshold, mark the element as to be removed; after all elements are marked, remove the corresponding elements to obtain the DOM nodes.

8. The apparatus for processing waterfall list items based on LLM according to claim 5, characterized in that: The sorting and numbering module specifically works as follows: Based on the list item selector, the DOM data of all list items is obtained. For each list item, a hash value is first generated for the specified content in the DOM data using `generate_content_hash`. Then, the hash value is bound to the corresponding element as a DOM attribute using `batch_inject_hash_attributes`. The DOM attribute is the `data-ba-uuid` attribute. Simultaneously, each list item is sorted based on its distance from the top of the browser window. Step S3 specifically involves: obtaining the corresponding list item data based on the sorted sequence, scrolling the list item to the visible area, highlighting it, taking a screenshot, and inputting the corresponding list item data, screenshot, and setting the processing prompt into the LLM for setting processing.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 4.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 4.