Summary of the invention
Technical matters to be solved by this invention is to provide a kind of Web information processing method and apparatus, the customized information of user cannot be shown in webpage, do not meet the problem of the individual demand of user to solve in prior art.
In order to solve the problem, the invention discloses a kind of Web information processing method, comprising:
Web-page requests is sent, the info web of download request to server;
Resolve the document object model tree that described info web is corresponding;
Search the target text information of each node in described document object model tree, described target text information is replaced with user individual content;
DOM Document Object Model after replacing is played up, and exports in corresponding web interface and show.
Preferably, described step target text information being replaced with user individual content comprises:
According to user individual amendment mapping table, this user individual amendment mapping table comprises the corresponding relation of target text information and individualized content, mates with described target text information;
The user individual content of coupling is replaced described target text information.
Preferably, comprise further:
User configures described user individual amendment mapping table, changes corresponding relation and/or target text information, the individualized content wherein of target text information and individualized content.
Preferably, described individualized content comprises: personalized Word message and/or personalized photo information.
Preferably, the step of searching the target text information of each node in described document object model tree described in comprises:
From the root node of described DOM Document Object Model, each node of traversed documents object model, obtains the target text information in each node.
Preferably, described the DOM Document Object Model step of carrying out playing up after replacing to be comprised:
Obtain the character types that described target text information is corresponding in former document object model tree;
After described personalized Word message is converted to described character types, carry out playing up displaying.
Preferably, described the DOM Document Object Model step of carrying out playing up after replacing to be comprised:
Obtain the font size of described target text information in former document object model tree in corresponding display structure;
The font size of described personalized Word message or the dimension of picture of personalized photo information are adjusted to the font size of described target text information.
Preferably, described in search the target text information of each node in described document object model tree, also comprise before described target text information is replaced with user individual content:
Judge whether the website information in web-page requests matches with the website information of replacing in URL library;
If coupling, then carry out described operation target text information being replaced with user individual content;
If do not mated, then do not carry out operation target text information being replaced with user individual content.
Preferably, described user individual amendment mapping table is kept at browser side;
Then the method comprises further:
According to user ID, the described user individual amendment mapping table being kept at browser side is uploaded to cloud server and stores.
Preferably, described user individual amendment mapping table is kept at server side;
Then the method comprises further:
Log in described server according to user ID, the described user individual amendment mapping table being kept at server is synchronized to browser side.
Accordingly, disclosed herein as well is a kind of Web information processing device, comprising:
Info web acquisition module, for sending web-page requests to server, the info web of download request;
Parsing module, for resolving document object model tree corresponding to described info web;
Replacement module, for searching the target text information of each node in described document object model tree, replaces with user individual content by described target text information;
Rendering module, for the DOM Document Object Model after replacing being played up, and exports in corresponding web interface and shows.
Preferably, described replacement module comprises:
Matching module, for revising mapping table according to user individual, this user individual amendment mapping table comprises the corresponding relation of target text information and individualized content, mates with described target text information;
First replacement module, for replacing described target text information by the user individual content of coupling.
Preferably, comprise further:
User configuration module, configures described user individual amendment mapping table for user, changes corresponding relation and/or target text information, the individualized content wherein of target text information and individualized content.
Preferably, described individualized content comprises: personalized Word message and/or personalized photo information.
Preferably, described replacement module comprises:
Node traverses judge module, for the root node from described DOM Document Object Model, each node of traversed documents object model, obtains the target text information in each node
Preferably, described rendering module comprises:
Character types acquisition module, for obtaining described target text information character types corresponding in former document object model tree
First plays up display module, after described personalized Word message is converted to described character types, carries out playing up displaying.
Preferably, described rendering module comprises:
Character size acquisition module, for obtaining the font size of described target text information in former document object model tree in corresponding display structure;
Second rendering module, for being adjusted to the font size of described target text information by the font size of described personalized Word message or the dimension of picture of personalized photo information.
Preferably, also comprise before described replacement module:
Network address judge module, for judging whether the website information in web-page requests matches with the website information of replacing in URL library;
If coupling, then carry out described operation target text information being replaced with user individual content;
If do not mated, then do not carry out operation target text information being replaced with user individual content.
Preferably, described user individual amendment mapping table is kept at browser side;
Then also comprise:
Upper transmission module, for according to user ID, is uploaded to cloud server by the described user individual amendment mapping table being kept at browser side and stores.
Preferably, described user individual amendment mapping table is kept at server side;
Then comprise further:
Synchronization module, for logging in described server according to user ID, is synchronized to browser side by the described user individual amendment mapping table being kept at server.
Compared with prior art, the present invention includes following advantage:
The present invention is by blocking the direct render process of browser to the document object model tree of info web, the target text information of each node in locating file object model tree, after described target text information is replaced with user individual content, again DOM Document Object Model (DOM, Document ObjectModel) tree is played up.So the customized information of user can be shown in webpage, the individual demand of user can be adapted to.
Embodiment
For enabling above-mentioned purpose of the present invention, feature and advantage become apparent more, and below in conjunction with the drawings and specific embodiments, the present invention is further detailed explanation.
One of core concept of the present invention is, carry out in traditional processing procedure at browser to info web, after being about to obtain dom tree corresponding to info web, directly play up in this process to dom tree, interception browser playing up directly to dom tree, plays up the dom tree after replacement after target text information being replaced with user individual content by device of the present invention in dom tree again.So the customized information of user can be shown in webpage, the individual demand of user can be adapted to.
A kind of Web information processing method and apparatus of the present invention is introduced in detail below by embodiment.
With reference to Fig. 1, show the schematic flow sheet of a kind of Web information processing method of the embodiment of the present invention,
Specifically can comprise:
Step 110, sends web-page requests to server, the info web of download request;
The major function of browser is presented the web resource (i.e. info web) that user selects, it needs from server request resource, and be presented in browser window, the form normally HTML (HTML (Hypertext Markup Language), Hypertext Markup Language) of resource.User specifies the position of institute's request resource with URI (UniformResource Identifier Uniform Resource Identifier).Namely user inputs URL in browser address bar, and browser then based on the request of described URL generating web page, is sent to the server that URL is corresponding, downloaded resources, i.e. the info web of download request.
Step 120, resolves the document object model tree that described info web is corresponding;
After browser downloads obtains info web, then resolve the dom tree that described info web is corresponding, in practice, dom tree is rendered as the tree construction (node tree) with element, attribute and text info webs such as html documents.
DOM is a kind of with platform with the irrelevant interface of language, and its allows the content of program and script dynamic access and amendment document, structure and type.It define a series of object and method carries out various random operation to the node of dom tree:
● Document object: as the most high node of tree, Document to as if entrance that whole document is operated.
● Element and Attr object: these node objects are all the mappings of a web document part, the deciding grade and level level of node reflects the structure of document just.
● Text object: as the child node of Element and Attr object, the Text object representation content of text of element or attribute.Text node no longer comprises any child node.
All nodes in dom tree are all inherited from node object, node object defines some the most basic attribute and methods, utilize these methods can realize traversal of tree, meanwhile, the title of node, value judge its type can also be learnt according to attribute.
So the present invention then based on the resolution rules of dom tree by info web, in reality, info web is source code, resolves to dom tree.
Step 130, searches the target text information of each node in described document object model tree, and described target text information is replaced with user individual content;
After obtaining dom tree corresponding to info web, this step is then searched each node in dom tree and whether be there is target text information, if existed, then described target text information is replaced with user individual content.
And before step 110 of the present invention is carried out, user's its individualized content configurable, individualized content can be user will need the corresponding relation carrying out replacing target text information and individualized content, " aircraft " in info web is such as needed to replace with Zhang Fei's machine picture, so word " aircraft " can carry out corresponding with local aircraft picture by user, and the corresponding relation of target text information and individualized content can be formed a user individual and revises mapping table by user in the present invention.
Preferably, described step target text information being replaced with user individual content comprises:
Steps A 11, according to user individual amendment mapping table, this user individual amendment mapping table comprises the corresponding relation of target text information and individualized content, mates with described target text information;
The corresponding relation of user individual amendment mapping table and the aforementioned target text information that arranged by user and individualized content to be replaced.
Wherein, described individualized content comprises: personalized Word message and/or personalized photo information.
Namely user can select the personalized Word message or the personalized photo information that target text information are replaced with oneself demand according to demand, such as the target text information " girlfriend " in info web, user can select " girlfriend " to replace with concrete name, or concrete photo.
In the present invention, when user selects target text information to replace with personalized Word message, personalized Word message to be replaced directly can be saved in personalized amendment mapping table with target text information correspondence position.When user selects target text information to replace with pictorial information, the store path that pictorial information is preserved in position corresponding with target text information in mapping table can be revised at user individual, when replacing, the embodiment of the present invention can be called picture according to path and replace.Or directly pictorial information is saved to position corresponding with target text information in user individual amendment mapping table.
So the present invention is when searching the target text information of each node in described document object model tree, then according to user individual amendment mapping table, this user individual amendment mapping table comprises the corresponding relation of target text information and individualized content, mate with described target text information, if matched, then proceed to steps A 12.
Steps A 12, replaces described target text information by the user individual content of coupling.
Such as aforesaid target text information " girlfriend " is matched, and the individualized content that in user individual amendment mapping table, " girlfriend " is corresponding is picture A, and picture A so can be used to replace described target text information " girlfriend ".
Preferably, comprise further:
Steps A 13, user configures described user individual amendment mapping table, changes corresponding relation and/or target text information, the individualized content wherein of target text information and individualized content.
As previously mentioned, user can configure described user individual amendment mapping table as required, such as remodify the corresponding relation of target text information and individualized content, such as the picture A that target text information " girlfriend " is corresponding is replaced with photo B, or change corresponding picture A into name.Such as user can revise target text information to be replaced again, such as target text information " girlfriend " is deleted, and such as adds target text information " automobile ", and the individualized content automobile photo of correspondence.
In the present invention, preferably, the step of searching the target text information of each node in described document object model tree described in comprises:
Step B11, from the root node of described DOM Document Object Model, each node of traversed documents object model, obtains the target text information in each node.
Dom tree is a tree structure, its information stores with wherein each node, so for ease of searching the target text information in info web, then can go through each node of DOM Document Object Model from the root node of dom tree, obtaining the target text information in each node.
In practice, can carry out recursive traversal during traversal, namely with reference to Fig. 2, there is root node A in dom tree, root node A exists child node A1, A2; There is child node A11 in node A1, A12; There is child node A111 in node A11, A112.During traversal, for each child node of a node, generally can child node travel through from left to right, such as have selected the child node A2 of root node A, travel through A2 and found that A2 does not exist child node, so returned root node A, travel through child node A1 according to root node A with the corresponding relation of child node; Then the child node A12 of traverse node A1, finds that A12 does not have child node, returns A1, travel through child node A11, by that analogy from A1.
That the target text information in available personalization amendment mapping table is mated with the Word message in each node, if matched, then enters replacement process at each node of traversal.
Step 140, plays up the DOM Document Object Model after replacing, and exports in corresponding web interface and show.
After the target text information in dom tree is replaced, then the dom tree after replacing is played up, play up complete exporting to again in corresponding web interface and show.
Preferably, described the DOM Document Object Model step of carrying out playing up after replacing to be comprised:
Step C11, obtains the character types that described target text information is corresponding in former document object model tree;
In former dom tree all there is corresponding attribute in each node, the font size of such as character, and the font etc. of character, to play up with its attribute when playing up, is then shown.So this step then obtains described target text information character types corresponding in former document object model tree.
Step C12, after described personalized Word message is converted to described character types, carries out playing up displaying.
Such as the font of target text information " girlfriend " in dom tree is upright Yao's body, if when the individualized content of " girlfriend " correspondence is name, then described name is converted to upright Yao's body, then carries out playing up displaying.
Preferably, described the DOM Document Object Model step of carrying out playing up after replacing to be comprised:
Step D11, obtains the font size of described target text information in former document object model tree in corresponding display structure;
The respective attributes that in former dom tree, each node all exists also comprises the font size in its corresponding display structure, position in such as place display interface, wide, high font size, so in order to not change the display structure of former info web, so need the individualized content of replacement to be adjusted to the size identical with former font size, not change the rendering result of dom tree when playing up.
The corresponding display structure of dom tree is controlled by corresponding CSS layout architecture body in practice, and so the present embodiment from the position CSS layout architecture body corresponding to target text information place node, can extract corresponding font size.
Step D12, is adjusted to the font size of described target text information by the font size of described personalized Word message or the dimension of picture of personalized photo information.
According to the font size of aforementioned obtained target text information, the font size of just described personalized Word message or the dimension of picture of personalized photo information are adjusted to the font size of described target text information.Can ensure to play up the result that obtains and former dom tree and play up coming to the same thing of obtaining, namely not change the display structure of former info web.
In addition, described in search the target text information of each node in described document object model tree, also comprise before described target text information is replaced with user individual content:
Step e 11, judges whether the website information in web-page requests matches with the website information of replacing in URL library;
Step e 12, if coupling, then carries out described operation target text information being replaced with user individual content;
Step e 13, if do not mated, does not then carry out operation target text information being replaced with user individual content.
In practice, user may select to show user individual content in which website, so the interpolation of the network address of these websites can enter and replace in URL library by user, so for the URL of user's request, then the network address in URL is mated with the network address of replacing in URL library, if matched, then carry out described operation target text information being replaced with user individual content; If do not mated, then do not carry out operation target text information being replaced with user individual content.
In addition, described user individual amendment mapping table can be kept at browser side;
So the present invention can comprise further:
Step F 11, according to user ID, is uploaded to cloud server by the described user individual amendment mapping table being kept at browser side and stores.
Time reality in, can there is a kind of account device in browser, user is at browser login user ID, and so browser can carry out with cloud server alternately.So according to user ID, the described user individual amendment mapping table being kept at browser side can be uploaded to cloud server and store.
So, when user logs in user ID again, from cloud server, user individual amendment table can be synchronized to this locality.
Namely described user individual amendment mapping table can be kept at server side;
So the present invention can comprise further:
Step F 11, logs in described server according to user ID, and the described user individual amendment mapping table being kept at server is synchronized to browser side.
With reference to Fig. 3, it illustrates a kind of Web information processing device of the present invention, it is characterized in that, comprising:
Info web acquisition module 310, for sending web-page requests to server, the info web of download request;
Parsing module 320, for resolving document object model tree corresponding to described info web;
Replacement module 330, for searching the target text information of each node in described document object model tree, replaces with user individual content by described target text information;
Rendering module 340, for the DOM Document Object Model after replacing being played up, and exports in corresponding web interface and shows.
Preferably, comprise with reference to replacement module described in Fig. 4:
Matching module 410, for revising mapping table according to user individual, this user individual amendment mapping table comprises the corresponding relation of target text information and individualized content, mates with described target text information;
First replacement module 420, for replacing described target text information by the user individual content of coupling.
Preferably, with reference to Fig. 5, comprise further:
User configuration module 430, configures described user individual amendment mapping table for user, changes corresponding relation and/or target text information, the individualized content wherein of target text information and individualized content.
Preferably, described individualized content comprises: personalized Word message and/or personalized photo information.
Preferably, with reference to Fig. 6, described replacement module comprises:
Node traverses judge module 510, for the root node from described DOM Document Object Model, each node of traversed documents object model, obtains the target text information in each node
Preferably, with reference to Fig. 7, described rendering module comprises:
Character types acquisition module 610, for obtaining described target text information character types corresponding in former document object model tree
First plays up display module 620, after described personalized Word message is converted to described character types, carries out playing up displaying.
Preferably, with reference to Fig. 8, described rendering module comprises:
Character size obtains mould 710, for obtaining the font size of described target text information in former document object model tree in corresponding display structure;
Second rendering module 720, for being adjusted to the font size of described target text information by the font size of described personalized Word message or the dimension of picture of personalized photo information.
Preferably, with reference to Fig. 9, also comprise before described replacement module:
Network address judges mould, 810, for judging whether the website information in web-page requests matches with the website information of replacing in URL library;
If coupling 820, then carry out described operation target text information being replaced with user individual content;
If do not mate 830, then do not carry out operation target text information being replaced with user individual content.
Preferably, with reference to Figure 10, described user individual amendment mapping table is kept at browser side;
Then also comprise:
Upper transmission module 910, for according to user ID, is uploaded to cloud server by the described user individual amendment mapping table being kept at browser side and stores.
Preferably, with reference to Figure 10, described user individual amendment mapping table is kept at server side;
Then this comprises further:
Synchronization module 920, for logging in described server according to user ID, is synchronized to browser side by the described user individual amendment mapping table being kept at server.
For aforesaid each embodiment of the method, in order to simple description, therefore it is all expressed as a series of combination of actions, but those skilled in the art should know, the embodiment of the present invention is not by the restriction of described sequence of movement, because according to the embodiment of the present invention, some step can adopt other orders or carry out simultaneously.Secondly, those skilled in the art also should know, the embodiment described in instructions all belongs to preferred embodiment, and involved action and module might not be that the embodiment of the present invention is necessary.
For device embodiment, due to itself and embodiment of the method basic simlarity, so description is fairly simple, relevant part illustrates see the part of embodiment of the method.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, and what each embodiment stressed is the difference with other embodiments, between each embodiment identical similar part mutually see.
Finally, also it should be noted that, in this article, the such as relational terms of first and second grades and so on is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.
Those skilled in the art should understand, embodiments of the invention can be provided as method, device or computer program.Therefore, the present invention can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the present invention can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disk memory, CD-ROM, optical memory etc.) of computer usable program code.
Method in the invention described above embodiment, device are applicable in various network or client environment, such as can be implemented in the computer equipment of such as PC device and so on, or can be implemented in other portable electric appts such as such as mobile phone, mobile communication equipment, personal digital assistant (PDA) or non-portable electronic equipment.Therefore those skilled in the art want it is clear that; protection scope of the present invention is not limited to the replacement function on PC in running browser, is only that the replacement function that have employed in embodiments of the present invention on PC in running browser is described for the succinct and convenient of description.
The present invention describes with reference to according to the process flow diagram of the method for the embodiment of the present invention, equipment (device) and computer program and/or block scheme.Should understand can by the combination of the flow process in each flow process in computer program instructions realization flow figure and/or block scheme and/or square frame and process flow diagram and/or block scheme and/or square frame.These computer program instructions can being provided to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, making the instruction performed by the processor of computing machine or other programmable data processing device produce device for realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be stored in can in the computer-readable memory that works in a specific way of vectoring computer or other programmable data processing device, the instruction making to be stored in this computer-readable memory produces the manufacture comprising command device, and this command device realizes the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be loaded in computing machine or other programmable data processing device, make on computing machine or other programmable devices, to perform sequence of operations step to produce computer implemented process, thus the instruction performed on computing machine or other programmable devices is provided for the step realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
Although describe the preferred embodiments of the present invention, those skilled in the art once obtain the basic creative concept of cicada, then can make other change and amendment to these embodiments.So claims are intended to be interpreted as comprising preferred embodiment and falling into all changes and the amendment of the scope of the invention.
Above to a kind of Web information processing method and apparatus provided by the present invention, be described in detail, apply specific case herein to set forth principle of the present invention and embodiment, the explanation of above embodiment just understands method of the present invention and core concept thereof for helping; Meanwhile, for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.