A method for automatic distribution of information
By customizing the rendering of HTML and Word documents, the problems of missing titles and body text styles, missing table borders, and unsmooth external image links during the HTML to Word conversion process were solved. This enabled the automatic combination and instant distribution of information, ensuring the aesthetics and accuracy of the Word document.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUHAN SHUMEI TECH CO LTD
- Filing Date
- 2022-11-21
- Publication Date
- 2026-05-22
AI Technical Summary
Existing technologies for converting HTML information to Word suffer from several issues, including insufficient custom rendering of titles and body text, missing table borders, table ranges exceeding document boundaries, and unsmooth rendering of external images. These issues result in insufficient aesthetics and accuracy, making it impossible to achieve real-time automatic information distribution.
By customizing the rendering of HTML and Word documents, using tokens to identify categories, modules, and product information, and combining BeautifulSoup and python-docx libraries, table and paragraph styles can be adjusted, and related images can be embedded to achieve automatic information combination and distribution.
It enables custom rendering of information in Word, solves problems such as missing styles, missing table borders, and unsmooth external image links, ensures that information reaches customers accurately in the first instance, and preserves the structure and aesthetics of HTML.
Smart Images

Figure CN115759005B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, specifically a method for automatic information distribution. Background Technology
[0002] Clients' demands for secondary editing of news articles mean that some news products also require editing to Word format; some products combine multiple news articles, which is very time-consuming and prone to errors. Clients require news to be delivered immediately, so news editors need to distribute it to clients on time via email or social media, which is cumbersome and difficult to time effectively.
[0003] The existing patent, "A Method and Terminal for Generating Intelligent Research Reports" (patent application number: CN201910743420.1), crawls information from the internet and achieves automated output of Word documents, solving the inconvenience of manual editing. However, copyright requirements for information mean that most information still requires manual intervention, and the automatically generated Word documents still need to be manually distributed to customers, failing to meet the requirement of accurately reaching customers in a timely manner.
[0004] The existing patent, "A Method and Apparatus for Converting HTML to Word Documents" (Patent Application No.: 201510802212.6), converts HTML information to Word while preserving the style. However, it neglects the presentation of tables, leading to aesthetic issues such as missing table borders and tables extending beyond the document boundaries. Furthermore, it fails to embed external image links within the Word document, resulting in less smooth and visually appealing image presentation.
[0005] Currently, among the backend software used to convert HTML to Word, LibreOffice, a widely used and high-performing program, also suffers from some style loss issues, just like other software. HTML content comes from many sources and uses a wide variety of fonts, which may not be supported when generating a Word document. Font incompatibility directly leads to style loss. Even if all fonts are supported, it still affects the overall aesthetics of the Word document. These programs also have issues such as missing table borders, table borders exceeding boundaries, and choppy rendering of external images.
[0006] Currently, methods for converting HTML to Word are all based on the established styles of HTML and cannot customize the rendering of Word according to the structure of the text in HTML, such as headings and body text. Summary of the Invention
[0007] To address the shortcomings of existing technologies, the present invention aims to provide a method for automatic information distribution, enabling customized rendering of titles and body text in Word; resolving the issue of missing styles in Word; and addressing aesthetic issues such as missing table borders, disordered text formatting within tables, and tables exceeding document boundaries, as well as the problem of unsmooth rendering of external images.
[0008] To achieve the above objectives, the technical solution adopted by the present invention is: a method for automatic information distribution, comprising the following steps:
[0009] Step S101. Edit the full text of the news article (HTML) and publish the news article;
[0010] Step S102. Determine the correspondence between the modules that record configuration information and the distribution objects;
[0011] Step S103. Extract the HTML body text and images, and then distribute the content to the enterprise WeChat group;
[0012] Step S104. Re-render the HTML;
[0013] Step S105. Convert the HTML information to Word;
[0014] Step S106. Re-render the Word document;
[0015] Step S107. Distribute the Word document via email.
[0016] This invention also discloses a method for automatic information distribution, comprising the following steps:
[0017] Step S201. Iterate through the products that are released at set times according to the preset time.
[0018] Step S202. Check if the release time of the scheduled product has arrived. If yes, proceed to step S203; otherwise, proceed to step S201.
[0019] Step S203. Check if the latest combination information already exists. If yes, proceed to step S201. If no, check if all the information that needs to be combined within the period has been published according to the modules included in the product. If yes, proceed to step S204. If no, proceed to step S201.
[0020] Step S204. Combine information (html);
[0021] Step S205. Re-render the HTML;
[0022] Step S206. Convert the HTML information to Word;
[0023] Step S207. Re-render the Word document;
[0024] Step S208. Locate the product's distribution configuration;
[0025] Step S209. Distribute the Word document to the WeChat group for the enterprise;
[0026] Step S210. Distribute the Word document via email.
[0027] Based on the above technical solution, the combined information HTML includes the following steps:
[0028] Step S301. The product contains multiple ordered categories. First, sort the product categories.
[0029] Step S302. The column contains multiple ordered modules. To assemble the column information HTML, first add the column information;
[0030] Step S303. Sort the modules of the column and traverse each module;
[0031] Step S304. Based on the product type, query the latest news details belonging to this module within the corresponding period, including the title and the main HTML text;
[0032] Step S305. Information related to the splicing module (html);
[0033] Step S306. Add product description to the information.html file.
[0034] Based on the above technical solution, in step S301, the formula for splicing the product's combination information is as follows:
[0035] P = L1 + L2 + L i +…+L n
[0036] Formula explanation: P represents the HTML of the combined information, L i This represents the combined information of the i-th column, and n represents the number of columns in the product.
[0037] Based on the above technical solution, in step S302, the formula for combining information in the column is as follows:
[0038] L = lm + M1 + M2 + M i +…+M n
[0039] lm=" "+lt+ln+" "
[0040] Formula Explanation: `lm` represents the category information, using the `p` tag in HTML; `lt` represents the category token string, uniquely identified by a string, followed by the category name `ln`; `L` represents the HTML of the category combination information, `M`... i This represents the combined information of the i-th module, and n represents the number of modules in the column;
[0041] The purpose of lt is to identify the category name through the token when re-rendering the word, and finally accurately render the category information using the category style.
[0042] Based on the above technical solution, in step S305, the formula for combining the module information is as follows:
[0043] M=" "+mt+title+" +body
[0044] Formula Explanation: M represents the HTML of the module information; the title of the module information is represented by the HTML p tag; mt represents the token string of the module information title, which is identified by a unique string and then appended with the title; body represents the HTML of the module information body.
[0045] The role of mt is to identify the following module information title through the token when re-rendering the word, and finally accurately render the title using the module information title style.
[0046] Based on the above technical solution, in step S306, the formula for splicing the head and tail of the product is as follows:
[0047] h=" "+jt+js+" "+" "+st+sj+" "
[0048] t=" "+mz+" "
[0049] P1 = h + P + t
[0050] Formula explanation: P represents the HTML of the information after all modules are concatenated, h and t represent the header and footer of the combined information respectively, and P1 represents the final combined information HTML;
[0051] The product description JavaScript is represented by the HTML p tag; jt represents the token string for the product description, which is identified by a unique string and then appended with the JavaScript.
[0052] Product time sj, represented by the HTML p tag; st represents the token string of product time, identified by a unique string, followed by sj;
[0053] The purpose of jt and st is to identify the product introduction and product time through the token when re-rendering the word, and finally accurately render the product introduction and product time using their respective styles.
[0054] All token strings have the same length to facilitate unified identification.
[0055] Based on the above technical solution, the re-rendering of HTML includes the following steps:
[0056] Step S401. Parse the information HTML to obtain the tree-structured HTML tag node object bs;
[0057] Step S402. Traverse the top-level paragraph tag nodes in the HTML;
[0058] Step S403. Recursively check child nodes;
[0059] Step S404. Determine if it is a string node. If yes, proceed to step S402; otherwise, proceed to step S405.
[0060] Step S405. Adjust the node font and determine whether the traversal of the top-level paragraph tag node of html has been completed. If yes, proceed to step S406; otherwise, proceed to step S402.
[0061] Step S406. Traverse the table nodes;
[0062] Step S407. Adjust the attributes of the table label nodes;
[0063] Step S408. Traverse each cell of the table label node.
[0064] Step S409. Adjust cell labels;
[0065] Step S410. Save the HTML file.
[0066] Based on the above technical solution, the re-rendering of Word includes the following steps:
[0067] Step S501. Initialize the Word document object; the read object docr is the original Word document object, and the write object docw is the newly rendered Word document object;
[0068] Step S502. The elements of the Word document object are contained within the object's body. Iterate through the list of elements in the body of the Word document.
[0069] Step S503. Check the type of the elements, including tables and paragraphs;
[0070] Step S504. Check if the element is a table element; if yes, proceed to step S505; if no, proceed to step S506.
[0071] Step S505. Insert the element into the element of the body of the writing object, and jump to step S502;
[0072] Step S506. Check if the paragraph is a heading. If yes, proceed to step S507; otherwise, proceed to step S508.
[0073] Step S507. Add a title to the writing object and jump to step S502;
[0074] Step S508. Add paragraphs to the writing object;
[0075] Step S509. Copy the text block of the paragraph to the write object;
[0076] Step S510. Determine whether the paragraph contains a related image. If yes, proceed to step S511; otherwise, proceed to step S502.
[0077] Step S511. Embed the associated image into the write object;
[0078] Step S512. Standardize the style of the table for writing objects;
[0079] Step S513. Save the write object docw as a Word file.
[0080] Based on the above technical solution, step S512 unifies the style of the table for writing objects, including the following steps:
[0081] Step S601. Traverse the list of tables in docw;
[0082] Step S602. Adjust the style of the table elements; set the alignment to center alignment and set the auto-adjust property;
[0083] Step S603. Traverse the cells of the table; the table consists of multiple rows, and each row contains multiple cells;
[0084] Step S604. Adjust the cell style; set the width to non-custom and set the auto-adjust property;
[0085] Step S605. For each cell, iterate through its paragraph list;
[0086] Step S606. For each paragraph in the cell, adjust the paragraph style: set the spacing between paragraphs to be equal.
[0087] The beneficial effects of this invention are as follows:
[0088] 1. The automatic information distribution system of this invention enables information Word products to automatically and accurately reach customers in the first instance. For information that needs to be sent to customers immediately, the automatic information distribution system converts the HTML information into Word format immediately after the information is edited, and then automatically sends it to customers via email or WeChat Work according to the distribution configuration associated with the information module tags. For information products such as daily newsletters that need to be combined and sent on a regular schedule, the system uses scheduled tasks to automatically combine the information according to module tags, then converts it into Word format, and finally automatically sends it to customers via email or WeChat Work according to the distribution configuration associated with the information product.
[0089] 2. The automatic information distribution system of this invention enables custom rendering of titles and body text in Word; it solves the problem of missing styles in Word; it resolves aesthetic issues such as missing table borders, disordered text formatting within tables, and tables exceeding document boundaries, as well as the problem of unsmooth rendering of external images. The Word document with a clear structure and fully preserved HTML styles provides an information experience indistinguishable from that on the web, and is even smoother. Attached Figure Description
[0090] Figure 1 This is a flowchart illustrating the overall process of information editing and real-time distribution in this invention.
[0091] Figure 2 This is a flowchart of the overall process for timed information distribution in the WORD document of this invention.
[0092] Figure 3 This is a flowchart of the algorithm for combining information in this invention;
[0093] Figure 4 This is a re-rendering of the HTML flowchart in this invention;
[0094] Figure 5 This is a re-rendering of the WORD flowchart in this invention;
[0095] Figure 6 This is a flowchart illustrating the unified table style in this invention;
[0096] Figure 7 Example image of editing news using Baidu Editor;
[0097] Figure 8 Example image for information preview;
[0098] Figure 9 Example diagram of distribution configuration;
[0099] Figure 10 Example image of sending information to WeChat groups for businesses;
[0100] Figure 11Example image of converting HTML to Word (without tables);
[0101] Figure 12 Example image of sending a Word document via email;
[0102] Figure 13 Example diagram of product configuration;
[0103] Figure 14 Configure example images for the column;
[0104] Figure 15 Example image of a combined information HTML preview;
[0105] Figure 16 Example image of converting HTML to Word (including tables);
[0106] Figure 17 Example image of distributing WORD documents to WeChat groups for businesses. Detailed Implementation
[0107] The following description, in conjunction with the accompanying drawings, further illustrates specific embodiments of the present invention, making the technical solution and its beneficial effects clearer and more explicit. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, but should not be construed as limiting the invention.
[0108] See Figure 1 As shown, this invention provides a method for information editing and real-time distribution:
[0109] 1. Use a rich text editor to edit the full text of the news article in HTML, then add fields such as title and module, and finally publish the news article.
[0110] 2. The distribution configuration records the correspondence between the module (or product) of the information and the distribution target (including email address and WeChat Work robot interface parameters). The module information of the information is used to find the email address and WeChat Work robot interface address for distribution.
[0111] 3. First, use regular expressions to match image tags in the news HTML to extract the plain text and images. Then, use the Enterprise WeChat robot API URL to call the Enterprise WeChat robot API to distribute the title, plain text, and images to the Enterprise WeChat group.
[0112] 4. Re-render the HTML.
[0113] 5. Use LibreOffice to convert HTML documents into Word documents.
[0114] 6. Re-render the Word document.
[0115] 7. Use the SMTP email sending interface to send Word files to the email addresses that need to be distributed.
[0116] See Figure 2 As shown, the present invention also provides a method for timed distribution of information via Word documents:
[0117] 1. A scheduled task iterates through the products that are published on a scheduled basis (including daily, weekly and monthly publications) every 5 minutes.
[0118] 2. Check the release time of the scheduled product. If the release time has not arrived, continue iterating through other scheduled products.
[0119] 3. If the time has arrived, check if the latest combined information already exists. If it does, continue iterating through other timed-released products. If the combined information does not exist, check if all the information that needs to be combined within the period (day, week, or month) has been released, based on the modules included in the product. If this condition is not met, continue iterating through other timed-released products.
[0120] 4. Based on the modules included in the product, combine the information of relevant modules within the combined cycle, including titles and body text. Then save the combined HTML information to the database.
[0121] 5. Re-render the combined information HTML.
[0122] 6. Use LibreOffice to convert the combined information HTML into a Word file.
[0123] 7. Re-render the Word document.
[0124] 8. Find the distribution configuration by product name to obtain the distribution email address or WeChat Work robot interface address.
[0125] 9. Use the Enterprise WeChat robot interface URL to call the Enterprise WeChat robot interface and distribute the Word document to the Enterprise WeChat group.
[0126] 10. Use the SMTP email sending interface to send Word files to the email addresses that need to be distributed.
[0127] See Figure 3 The algorithm for combining information is shown below:
[0128] 1. The product contains multiple ordered sections. First, sort the product sections.
[0129] The formula for combining product information is shown below:
[0130] P = L1 + L2 + L i +…+L n
[0131] Formula explanation: P represents the combined information (html), L i This represents the combined information of the i-th column, and n represents the number of columns in the product.
[0132] 2. The column contains multiple ordered modules. To assemble the column information HTML, first add the column information.
[0133] The formula for combining information from different sections is shown below:
[0134] L = lm + M1 + M2 + M i +…+M n
[0135] lm=" "+lt+ln+" "
[0136] Formula Explanation: The column information (lm) is represented by the HTML `` tag. `lt` represents the column's token string, uniquely identified, followed by the column name (ln). `L` represents the HTML of the column combination information. i This represents the combined information of the i-th module, and n represents the number of modules in the column.
[0137] The purpose of lt is to identify the category name through the token when re-rendering the word, and finally accurately render the category information using the category style.
[0138] 3. Sort the modules of the column and traverse each module.
[0139] 4. Based on the product type (daily, weekly, monthly), retrieve the details of the latest news article belonging to that module within the corresponding period, including the title and the full HTML text.
[0140] 5. Information related to the splicing module (HTML).
[0141] The formula for combining module information is shown below:
[0142] M=" "+mt+title+" +body
[0143] Formula Explanation: M represents the HTML of the module information. The module information title is represented by the HTML `` tag. `mt` represents the token string of the module information title, uniquely identified and appended with the title. `body` represents the HTML body of the module information.
[0144] The role of mt is to identify the following module information title through the token when re-rendering the word, and finally accurately render the title using the module information title style.
[0145] 6. After combining the main information about the product, finally add the product name, description, date, disclaimer, and other information.
[0146] The formula for splicing the head and tail of the product is as follows:
[0147] h=" "+jt+js+" "+" "+st+sj+" "
[0148] t=" "+mz+" "
[0149] P1 = h + P + t
[0150] Formula explanation: P represents the HTML of the combined information after all modules are concatenated, h and t represent the header and footer of the combined information respectively, and P1 represents the final combined information HTML.
[0151] The product description JavaScript file uses the `` tag in HTML. `jt` represents the product description token string, uniquely identified by a string, followed by the JavaScript file.
[0152] Product time (sj) is represented by the HTML p tag. st represents the token string for the product time, which is a unique string identifier, followed by sj.
[0153] The purpose of jt and st is to identify the product introduction and product time through the token when re-rendering the word, and finally accurately render the product introduction and product time using their respective styles.
[0154] All token strings have the same length to facilitate unified identification.
[0155] See Figure 4 The process of re-rendering HTML is explained below:
[0156] 1. Use the BeautifulSoup library to parse the HTML information and obtain a tree-structured HTML tag node object bs.
[0157] Each node can directly find its sibling nodes and child nodes.
[0158] 2. Traverse the top-level HTML `` tag nodes, i.e., " "Label.
[0159] The traversal method is as follows:
[0160] Find the first p tag node p1 directly from bs.
[0161] By finding all the sibling nodes of p1, we can obtain all the top-level p nodes.
[0162] 3. After finding all top-level p nodes, recursively check the child nodes of the top-level p nodes.
[0163] If a node is a string node, it means that it has no child nodes.
[0164] 4. If the node is a string node, continue traversing to the next top-level p node.
[0165] 5. If the node is not a leaf node, unify the font and adjust the font-family property.
[0166] Check the style attribute of the node tag n. If it does not exist, assign a value to the style attribute using the default font defaultff.
[0167] If the style attribute exists, check the font-family sub-attribute of the style attribute and replace its value with defaultff.
[0168] 6. After traversing the top-level p node, traverse the table nodes, i.e., " "Labels. Table node list tlist filtered by bs"
[0169]
[0170]
[0171] 7. Adjust the attributes of the table tag node: Set the width attribute of the table tag to match the width sub-attribute value of the style attribute. Specifically: Check the attribute list of the table tag t; if it contains both style and width attributes, extract the value sw of the width sub-attribute of the style attribute and assign it to the width attribute of t. 8. Traverse each cell of the table tag node, i.e., " "Label.
[0172] Filtering the cell list tdlist using bs The tag was obtained.
[0173] 9. Set the style of td cells uniformly.
[0174] For the sub-properties of the style attribute of the cell tag ce, including the top border (border-top), bottom border (border-bottom), left border (border-left), and right border (border-right), if none of them exist, add them uniformly, and keep the line thickness, color, etc. consistent.
[0175] If there is only one or a few of the top, bottom, left, and right boundary lines, then fill in the other boundary lines, keeping the thickness, color, etc. consistent.
[0176] 10. Finally, save the HTML file.
[0177] See Figure 5 The following is a description of the process for re-rendering a Word document:
[0178] 1. Use python-docx to parse Word documents and initialize Word document objects: read object docr is the original Word document object, and write object docw is the newly rendered Word document object.
[0179] 2. The elements of a Word document object are contained within the object's body. Iterate through the list of elements in the docr's body.
[0180] 3. Check the type of the elements, including tables and paragraphs.
[0181] 4. Check if the element is a table element.
[0182] 5. If it is a table, insert the element into the body element of the writing object.
[0183] 6. If it is a paragraph element, check if the paragraph is a heading using the following method:
[0184] 1) First, obtain the text pt of paragraph para.
[0185] 2) Iterate through the list of token strings, including the product introduction token string jt, the product time token string st, the category token string lt, and the module token string mt, all with the same length tl.
[0186] 3) Check the length pl of pt. If pl <= tl, continue to traverse other token strings; otherwise, check if the token string is equal to the substring of length tl before pt. If they are equal, it is determined that the paragraph element is a heading, and the heading level is also determined; otherwise, continue to traverse other token strings.
[0187] 4) If no token string is matched, then the paragraph element is not a heading.
[0188] 7. If the paragraph element is a heading, add the heading using the following method:
[0189] 1) Cut off the length of tl from pt to get the actual title text rpt.
[0190] 2) Add a title to the writing object based on the title level and title text rpt.
[0191] 3) The font size, style, alignment, color, bolding, and underline of newly added titles should be set uniformly according to the title level.
[0192] 8. If the paragraph element is not a heading, add a paragraph body paraw to the writing object and uniformly set the paragraph style, including first-line indentation, line spacing, paragraph spacing, etc.
[0193] 9. Paragraphs are divided into different text blocks according to style (including color, font, weight, underline, italics, etc.). The list of text blocks for the paragraph in the reading object is called a runslist. Copy the text blocks from the runslist to the writing object, as follows:
[0194] 1) Iterate through the text blocks runr in runslist and get their text runrtext.
[0195] 2) Write the newly added paragraph paraw of the object, and add the text block according to the text block runrtext.
[0196] 3) Assign values to the style properties of the newly added text block according to the runr's style, including color, etc.
[0197] 10. The criterion for determining whether a paragraph contains an associated image is whether the paragraph's XML attribute value (paraxml) contains the characteristic string "rId". If the paraxml contains "rId", then the paragraph contains an associated image.
[0198] 11. If a paragraph contains a related image, embed the related image into the write object. The specific steps are as follows:
[0199] 1) Use regular expression matching to find the associated image ID (imgid) after "rId", which is a numeric type.
[0200] 2) Obtain the image URL (imgurl) through the image's associated ID (imgid).
[0201] 3) Check if the file extension of the imgurl matches the file extension of an image (jpg, png, jpeg, etc.). If it does not match, end the embedding operation.
[0202] 4) Download the file to your local computer via the image link (imgurl).
[0203] 5) Then add a new paragraph to docw, and in the new paragraph, add a local image with an appropriate width to complete the image embedding.
[0204] 12. After iterating through the element list of the object's body, uniformly write the table styles for the object, including properties such as auto-adjustment.
[0205] 13. Finally, save the docw object as a Word file.
[0206] See Figure 6 The process for standardizing table styles is shown below:
[0207] 1) Traverse the list of tables in docw.
[0208] 2) Adjust the style of the table elements. Set the alignment to center and enable auto-alignment.
[0209] 3) Traverse the cells of the table. The table consists of multiple rows, and each row contains multiple cells.
[0210] 4) Adjust the cell style. Set the width to non-custom and enable the auto-adjust property.
[0211] 5) For each cell, iterate through its list of paragraphs.
[0212] 6) Adjust the paragraph style for each paragraph in the cell: set the spacing between paragraphs to be equal.
[0213] Example 1: Information editing and instant distribution.
[0214] 1. News editors use Baidu's ueditor editor, such as... Figure 7 As shown;
[0215] Use Baidu Editor to edit the full HTML text of the news article, then add fields such as title and module, and publish the article. See the news preview below. Figure 8 As shown.
[0216] 2. The correspondence between the modules (or products) that record the distribution configuration information and the distribution targets (including email addresses and WeChat Work robot interface URLs). For example... Figure 9 As shown;
[0217] 3. When publishing information, call the WeChat Work robot interface to distribute the title (whether to distribute depends on the distribution configuration), the plain text body, and images to the WeChat Work group. For example... Figure 10 As shown;
[0218] 4. The HTML document was re-rendered, fonts were standardized, and then it was converted to Word using LibreOffice's conversion commands. Finally, the Word document was re-rendered using python-docx, preserving the HTML styles (including colors, bolding, etc.). Related images were embedded into the Word document, such as... Figure 11 As shown;
[0219] 5. Based on the distribution configuration, use the SMTP email sending interface to send a Word file to the corresponding email address, such as... Figure 12 As shown.
[0220] Example 2: Timed Distribution of Word Documents
[0221] 1. The scheduled task iterates through the scheduled publication products (including daily, weekly, and monthly publications) at regular intervals (every 5 minutes) according to the product configuration. Product configurations are as follows: Figure 13 As shown;
[0222] A product contains multiple sections, such as Figure 13 As shown. A section contains multiple modules, such as... Figure 14 As shown. For products released on a schedule, if the scheduled time arrives, check if the latest combined information already exists. If it does, continue iterating through other products released on a schedule. If the combined information does not exist, check if all the information that needs to be combined within the period (day, week, or month) has been released, based on the modules included in the product. If this condition is not met, continue iterating through other products released on a schedule.
[0223] 2. Based on the relationship between products and modules, the information published by relevant modules within the combined cycle, including titles and body text. A preview of the combined information in HTML is shown below. Figure 15 As shown;
[0224] 3. The HTML document is re-rendered, adjusting table and cell styles; then converted to Word; finally, the Word document is re-rendered, identifying body text or headings (and heading levels) by matching unique tokens. Headings are rendered with custom styles based on heading levels, and body text is rendered using body text styles. After rendering, category information, module titles, and body text each have their own independent styles, table borders are complete, and table sizes automatically adjust. Paragraph spacing within tables is equal. The overall structure is clear and aesthetically pleasing. An example of a Word document containing tables is shown below. Figure 16 As shown;
[0225] 4. Find the distribution configuration by product name to obtain the distribution email address or WeChat Work robot interface URL. Call the WeChat Work robot interface to distribute the Word document to the WeChat Work group. Example of WeChat Work group distribution: Figure 17 As shown.
[0226] 5. Based on the distribution configuration, use the SMTP email sending interface to send a Word file to the corresponding email address.
[0227] In the description of this specification, references to terms such as "an embodiment," "preferred," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. Illustrative expressions of the above terms in this specification do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0228] This invention is not limited to the embodiments described above. Those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications are also considered within the scope of protection of this invention. Contents not described in detail in this specification are prior art known to those skilled in the art.
Claims
1. A method for automatic information distribution, characterized in that, It includes the following steps: Step S101. Edit the full text of the information html and publish the information; Step S102. Distribute the correspondence between the module for recording information and the distribution objects; Step S103. Extract the pure text and pictures of the html body, and then distribute the content to the enterprise WeChat group; Step S104. Re-render the html; Step S105. Convert the information html to word; Step S106. Re-render the word; Step S107. Distribute the word via email; The re-rendering of the html includes the following steps: Step S401. Parse the information html to obtain the html tag node object bs in a tree structure; Step S402. Traverse the top-level paragraph tag nodes of the html; Step S403. Recursively check the sub-nodes; Step S404. Determine whether it is a string node. If so, jump to Step S402; if not, jump to Step S405; Step S405. Adjust the font of the node, and determine whether the traversal of the top-level paragraph tag nodes of the html is completed. If so, jump to Step S406; if not, jump to Step S402; Step S406. Traverse the table nodes; Step S407. Adjust the attributes of the table tag nodes; Step S408. Traverse each cell of the table tag node Step S409. Adjust the cell tag; Step S410. Save the html file.
2. A method for automatic information distribution, characterized in that, It includes the following steps: Step S201. Traverse the products to be released regularly according to the preset time; Step S202. Check whether the release time of the products to be released regularly has arrived. If so, jump to Step S203; if not, jump to Step S201; Step S203. Check whether the latest combined information already exists. If so, jump to Step S201; if not, check whether all the information to be combined within the cycle has been published according to the modules included in the product. If so, jump to Step S204; if not, jump to Step S201; Step S204. Combine the information html; Step S205. Re-render the html; Step S206. Convert the information html to word; Step S207. Re-render the word; Step S208. Find the distribution configuration of the product; Step S209. Distribute the word to the enterprise WeChat group; Step S210. Distribute the word via email; The re-rendering of the html includes the following steps: Step S401. Parse the information html to obtain the html tag node object bs in a tree structure; Step S402. Traverse the top-level paragraph tag nodes of the html; Step S403. Recursively check the sub-nodes; Step S404. Determine whether it is a string node. If so, jump to Step S402; if not, jump to Step S405; Step S405. Adjust the font of the node, and determine whether the traversal of the top-level paragraph tag nodes of the html is completed. If so, jump to Step S406; if not, jump to Step S402; Step S406. Traverse the table nodes; Step S407. Adjust the attributes of the table tag nodes; Step S408. Traverse each cell of the table label node. Step S409. Adjust cell labels; Step S410. Save the HTML file.
3. The method for automatic information distribution as described in claim 2, characterized in that: The combined information HTML includes the following steps: Step S301. The product contains multiple ordered categories. First, sort the product categories. Step S302. The column contains multiple ordered modules. To assemble the column information HTML, first add the column information; Step S303. Sort the modules of the column and traverse each module; Step S304. Based on the product type, query the latest news details belonging to this module within the corresponding period, including the title and the main HTML text; Step S305. Information related to the splicing module (HTML); Step S306. Add product descriptions to the information HTML.
4. The method for automatic information distribution as described in claim 3, characterized in that: In step S301, the formula for combining product information is as follows: P= + + + … + ; Formula explanation: P represents the HTML of the combined information. This represents the combined information of the i-th column, and n represents the number of columns in the product.
5. The method for automatic information distribution as described in claim 3, characterized in that: In step S302, the formula for combining information in the column is as follows: L=lm + + + + … + ; lm = ” "+ lt + ln + " ” Formula Explanation: `lm` represents the category information, using the `p` tag in HTML; `lt` represents the category token string, uniquely identified by a string, followed by the category name `ln`; `L` represents the HTML of the category combination information. This represents the combined information of the i-th module, and n represents the number of modules in the column; The purpose of lt is to identify the category name through the token when re-rendering the word, and finally accurately render the category information using the category style.
6. The method for automatic information distribution as described in claim 3, characterized in that: In step S305, the formula for concatenating the combined information of the modules is as follows: M = ” "+ mt + title + " ” + body Formula Explanation: M represents the HTML of the module information; the title of the module information is represented by the HTML p tag; mt represents the token string of the module information title, which is identified by a unique string and then appended with the title; body represents the HTML of the module information body. The role of mt is to identify the following module information title through the token when re-rendering the word, and finally accurately render the title using the module information title style.
7. The method for automatic information distribution as described in claim 3, characterized in that: In step S306, the formula for splicing the head and tail of the product is as follows: h = ” "+ jt + js + " ” + ” "+ st + sj + " ” t = ” "+ mz + " ” P1 = h + P + t Formula explanation: P represents the HTML of the information after all modules are concatenated, h and t represent the header and footer of the combined information respectively, and P1 represents the final combined information HTML; The product description JavaScript is represented by the HTML p tag; jt represents the token string for the product description, which is identified by a unique string and then appended with the JavaScript. Product time sj, represented by the HTML p tag; st represents the token string of product time, identified by a unique string, followed by sj; The purpose of jt and st is to identify the product introduction and product time through the token when re-rendering the word, and finally accurately render the product introduction and product time using their respective styles. All token strings have the same length to facilitate unified identification.
8. The method for automatic information distribution as described in claim 1 or 2, characterized in that, The re-rendering of the Word document includes the following steps: Step S501. Initialize the Word document object; the read object docr is the original Word document object, and the write object docw is the newly rendered Word document object; Step S502. The elements of the Word document object are contained within the object's body. Iterate through the list of elements in the docr's body. Step S503. Check the type of the elements, including tables and paragraphs; Step S504. Check if the element is a table element; if yes, proceed to step S505; if no, proceed to step S506. Step S505. Insert the element into the element of the body of the writing object, and jump to step S502; Step S506. Check if the paragraph is a heading. If yes, proceed to step S507; otherwise, proceed to step S508. Step S507. Add a title to the writing object and jump to step S502; Step S508. Add paragraphs to the writing object; Step S509. Copy the text block of the paragraph to the write object; Step S510. Determine whether the paragraph contains a related image. If yes, proceed to step S511; otherwise, proceed to step S502. Step S511. Embed the associated image into the write object; Step S512. Standardize the style of the table for writing objects; Step S513. Save the write object docw as a Word file.
9. The method for automatic information distribution as described in claim 8, characterized in that, In step S512, the style of the table for writing objects is standardized, including the following steps: Step S601. Traverse the list of tables in docw; Step S602. Adjust the style of the table elements; set the alignment to center alignment and set the auto-adjust property; Step S603. Traverse the cells of the table; the table consists of multiple rows, and each row contains multiple cells; Step S604. Adjust the cell style; set the width to non-custom and set the auto-adjust property; Step S605. For each cell, iterate through its list of paragraphs; Step S606. For each paragraph in the cell, adjust the paragraph style: set the spacing between paragraphs to be equal.