Summary of the invention
The fundamental purpose of the embodiment of the invention is to provide a kind of method and system of obtaining 2 D code information from webpage.
The purpose of the embodiment of the invention is achieved by following technical proposals:
A kind of method of obtaining 2 D code information from webpage is characterized in that, comprising:
Each node in the traversal webpage judges whether present node is the picture node;
If present node is the picture node, then obtain the pictorial information of this picture node;
According to the pictorial information that obtains, judge whether this pictorial information is two-dimension code image;
If this pictorial information is two-dimension code image, then identify this two-dimension code image, obtain the 2 D code information of storing in this two-dimension code image;
Set up the corresponding relation between this 2 D code information and the respective two-dimensional sign indicating number picture node.
If described present node is the picture node, then obtain the pictorial information of this picture node, comprising:
If present node is the picture node, judge then whether this picture node shows;
If described picture node shows, then obtain the pictorial information of this picture node.
Also comprise:
After receiving the instruction of clicking this two-dimension code image node, show the corresponding 2 D code information of described two-dimension code image node, perhaps link to the 2 D code information network address pointed of described two-dimension code image node correspondence.
Also comprise:
Set up and described two-dimension code image node corresponding buttons;
After receiving the instruction of clicking described button, show the corresponding 2 D code information of described two-dimension code image node, perhaps link to the 2 D code information network address pointed of described two-dimension code image node correspondence.
A kind of system that obtains 2 D code information from webpage is characterized in that, comprising: node traversal unit, pictorial information acquiring unit, two-dimension code image judging unit, two-dimension code image recognition unit, 2 D code information corresponding unit;
Described node traversal unit for each node of traversal webpage, judges whether present node is the picture node;
Described pictorial information acquiring unit is used for obtaining the pictorial information of this picture node when present node is the picture node;
Described two-dimension code image judging unit is used for according to the pictorial information that obtains, and judges whether this pictorial information is two-dimension code image;
Described two-dimension code image recognition unit is used for identifying this two-dimension code image when this pictorial information is two-dimension code image, obtains the 2 D code information of storing in this two-dimension code image;
Described 2 D code information corresponding unit is used for setting up the corresponding relation between this 2 D code information and the respective two-dimensional sign indicating number picture node.
Also comprise: the picture node shows judging unit;
Described picture node shows judging unit, is used for judging whether this picture node shows when present node is the picture node;
Described pictorial information acquiring unit is used at this picture node obtaining the pictorial information of this picture node when showing.
Also comprise: the two-dimension code performance element;
Described two-dimension code performance element, be used for after receiving the instruction of clicking described two-dimension code image node, show the corresponding 2 D code information of described two-dimension code image node, perhaps link to the 2 D code information network address pointed of described two-dimension code image node correspondence.
Also comprise: the two-dimension code button is set up unit and two-dimension code performance element;
Described two-dimension code button is set up the unit, is used for setting up and described two-dimension code image node corresponding buttons;
Described two-dimension code performance element is used for showing the corresponding 2 D code information of described two-dimension code image node after receiving the instruction of clicking described button, perhaps links to the 2 D code information network address pointed of described two-dimension code image node correspondence.
By the embodiment of the invention, the user need not to utilize other terminal to take or scan to obtain relevant 2 D code information, but can directly can obtain relevant 2 D code information by this browser, and is convenient for users.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, below in conjunction with embodiment and accompanying drawing, the present invention is described in further details.At this, exemplary embodiment of the present invention and explanation thereof are used for explanation the present invention, but not as a limitation of the invention.
Embodiment one
Fig. 1 is the process flow diagram that obtains the method for 2 D code information from webpage.As shown in the figure, should from webpage, obtain the method for 2 D code information, comprise:
S1, each node in the traversal webpage judges whether present node is the picture node;
Concrete, can come by the DOM Tree of webpage each node of webpage is traveled through.DOM Tree refers to by DOM html page be resolved, and the HTML tree tree structure and the corresponding access method that generate.
S2 if present node is the picture node, then obtains the pictorial information of this picture node;
S3 according to the pictorial information that obtains, judges whether this pictorial information is two-dimension code image;
Here, we can be sent to described pictorial information the two-dimension code image recognition unit and carry out two-dimension code identification, whether can successfully identify two-dimension code according to this recognition device and judge whether this pictorial information is two-dimension code image.
S4 if this pictorial information is two-dimension code image, then identifies this two-dimension code image, obtains the 2 D code information of storing in this two-dimension code image;
S5 sets up the corresponding relation between this 2 D code information and the respective two-dimensional sign indicating number picture node.
The embodiment of the invention may be implemented in the browser in the specific implementation.When user's open any browser browsing page, after having loaded, webpage can start the above-mentioned method of from webpage, obtaining 2 D code information.The method that the embodiment of the invention provides is identified each picture node in the webpage one by one, be two-dimension code image if successfully identify picture, then obtain the 2 D code information of this picture and set up corresponding relation with this picture node, when carrying out associative operation, can obtain the corresponding 2 D code information of this picture node in order to the user.By said method, the user need not to utilize other terminal to take or scan to obtain relevant 2 D code information, but can directly can obtain relevant 2 D code information by this browser, and is convenient for users.
Should be pointed out that the method that the invention described above embodiment provides is not limited in the portable terminal use, suitable equally in fixed terminals such as PC.
Embodiment two
Owing to have part picture node not show in the webpage, and two-dimension code image must show at webpage.Therefore, in the present embodiment, whether we also show to come further according to the picture node is screened the picture node, to improve the treatment effeciency of this method.As shown in Figure 2, preferably, if described present node is the picture node, then obtain the pictorial information of this picture node, comprising:
S21 if present node is the picture node, judges then whether this picture node shows;
S22, if this picture node do not show, then ignore this node, do not deal with.
S23, if this picture node show, then obtain the pictorial information of this picture node.
As previously mentioned, because two-dimension code image must show at webpage, therefore the picture node that does not show is inevitable is not our needed two-dimension code image node.We can filter out the two-dimension code image node faster by above-mentioned determining step, improve the treatment effeciency of this method.
About the judgement whether node shows, whether we can be " none " by " display " property value in the render tree of this node correspondence, and perhaps whether " visibility " property value is that " hidden " judges.For example,<img src="/images/LOGO.png "/style=" display:none; "〉namely illustrates the node of this node for not showing, do not need that therefore it is carried out two-dimension code image and judges.
Embodiment three
Present embodiment is on the basis of previous embodiment one, and the described method of obtaining 2 D code information from webpage also comprises:
After receiving the instruction of clicking this two-dimension code image node, show the 2 D code information that this two-dimension code image node is corresponding, perhaps link to the 2 D code information network address pointed of this two-dimension code image node correspondence.
The scheme that provides according to present embodiment, behind the corresponding relation of setting up between 2 D code information and the respective two-dimensional sign indicating number picture node, the user can realize the operation of obtaining this 2 D code information or linking to the corresponding 2 D code information of this two-dimension code image node network address pointed by clicking this two-dimension code image nodal operation.
By present embodiment, the user need not to utilize other terminal to take or scan to obtain relevant 2 D code information, but can directly can obtain relevant 2 D code information by this browser, and is convenient for users.
Embodiment four
Present embodiment is on the basis of previous embodiment one, and the described method of obtaining 2 D code information from webpage also comprises:
Set up and described two-dimension code image node corresponding buttons;
After receiving the instruction of clicking described button, show the 2 D code information that this two-dimension code image node is corresponding, perhaps link to the 2 D code information network address pointed of this two-dimension code image node correspondence.
By present embodiment, behind the corresponding relation of setting up between 2 D code information and the respective two-dimensional sign indicating number picture node, can be on this picture the display reminding user this be the button of a two-dimension code image.When the user clicks this button, then show this 2 D code information or link to the corresponding 2 D code information of this two-dimension code image node network address pointed.
Embodiment five
Fig. 3 is the structural representation that obtains the system of 2 D code information from webpage.As shown in the figure, should from webpage, obtain the system of 2 D code information, comprise:node traversal unit 1, pictorialinformation acquiring unit 2, two-dimension codeimage judging unit 3, two-dimension codeimage recognition unit 4,2 D codeinformation corresponding unit 5.
Describednode traversal unit 1 for each node of traversal webpage, judges whether present node is the picture node;
Concrete, thisnode traversal unit 1 can come by the DOM Tree of webpage each node of webpage is traveled through.DOM Tree refers to by DOM html page be resolved, and the HTML tree tree structure and the corresponding access method that generate.
Described pictorialinformation acquiring unit 2 is used for obtaining the pictorial information of this picture node when present node is the picture node;
Described two-dimension codeimage judging unit 3 is used for according to the pictorial information that obtains, and judges whether this pictorial information is two-dimension code image;
Described two-dimension codeimage recognition unit 4 is used for identifying this two-dimension code image when this pictorial information is two-dimension code image, obtains the 2 D code information of storing in this two-dimension code image;
Here, this two-dimension codeimage judging unit 3 and two-dimension codeimage recognition unit 4 can combine, carry out two-dimension code identification by described pictorial information being sent to the two-dimension code image recognition unit, whether can successfully identify two-dimension code according to this recognition device and judge whether this pictorial information is two-dimension code image.This scheme also should be within protection scope of the present invention.
Described 2 D codeinformation corresponding unit 5 is used for setting up the corresponding relation between this 2 D code information and the respective two-dimensional sign indicating number picture node.
The embodiment of the invention may be implemented in the browser in the specific implementation.When user's open any browser browsing page, after having loaded, webpage can start the above-mentioned system that from webpage, obtains 2 D code information.The system that the embodiment of the invention provides identifies each picture node in the webpage one by one, be two-dimension code image if successfully identify picture, then obtain the 2 D code information of this picture and set up corresponding relation with this picture node, when carrying out associative operation, can obtain the corresponding 2 D code information of this picture node in order to the user.By said system, the user need not to utilize other terminal to take or scan to obtain relevant 2 D code information, but can directly can obtain relevant 2 D code information by this browser, and is convenient for users.
Should be pointed out that the system that the invention described above embodiment provides is not limited in the portable terminal use, suitable equally in fixed terminals such as PC.
Embodiment six
Owing to have part picture node not show in the webpage, and two-dimension code image must show at webpage.Therefore, in the present embodiment, whether we also show to come further according to the picture node is screened the picture node, to improve the treatment effeciency of this method.As shown in Figure 4, preferably, should obtain the system of 2 D code information from webpage, also comprise: the picture node shows judging unit 6.
Described picture node shows judging unit 6, is used for judging whether this picture node shows when present node is the picture node;
Described pictorialinformation acquiring unit 2 is used at this picture node obtaining the pictorial information of this picture node when showing.
As previously mentioned, because two-dimension code image must show at webpage, therefore the picture node that does not show is inevitable is not our needed two-dimension code image node.We show by above-mentioned picture node whether 6 pairs of picture nodes of judging unit show that judgement can filter out the two-dimension code image node faster, improves the treatment effeciency of this method.
The judgement that whether shows about node, the picture node shows whether judging unit 6 can be " none " by " display " property value in the render tree of this node correspondence, and perhaps whether " visibility " property value is that " hidden " judges.For example,<img src="/images/LOGO.png "/style=" display:none; "〉namely illustrates the node of this node for not showing, do not need that therefore it is carried out two-dimension code image and judges.
Embodiment seven
Present embodiment is on the basis of previous embodiment five, and the described system that obtains 2 D code information from webpage also comprises: the two-dimension code performance element.
Described two-dimension code performance element is used for showing the 2 D code information that this two-dimension code image node is corresponding after receiving the instruction of clicking this two-dimension code image node, perhaps links to the 2 D code information network address pointed of this two-dimension code image node correspondence.
The scheme that provides according to present embodiment, behind the corresponding relation of setting up between 2 D code information and the respective two-dimensional sign indicating number picture node, the user can realize the operation of obtaining this 2 D code information or linking to the corresponding 2 D code information of this two-dimension code image node network address pointed by clicking this two-dimension code image nodal operation.
By present embodiment, the user need not to utilize other terminal to take or scan to obtain relevant 2 D code information, but can directly can obtain relevant 2 D code information by this browser, and is convenient for users.
Embodiment eight
Present embodiment is on the basis of previous embodiment five, and the described system that obtains 2 D code information from webpage also comprises: the two-dimension code button is set up unit and two-dimension code performance element.
Described two-dimension code button is set up the unit, is used for setting up and described two-dimension code image node corresponding buttons;
Described two-dimension code performance element is used for showing the 2 D code information that this two-dimension code image node is corresponding after receiving the instruction of clicking described button, perhaps links to the 2 D code information network address pointed of this two-dimension code image node correspondence.
By present embodiment, after 2 D codeinformation corresponding unit 5 is set up corresponding relation between 2 D code information and the respective two-dimensional sign indicating number picture node, the two-dimension code button set up the unit can be on this picture the display reminding user this be the button of a two-dimension code image.When the user clicked this button, the two-dimension code performance element then showed this 2 D code information or links to the corresponding 2 D code information of this two-dimension code image node network address pointed.
In sum, the embodiment of the invention provides a kind of method and system of obtaining 2 D code information from webpage.These method and system are by each node in the convenient webpage, and identification two-dimension code image node wherein, set up the corresponding relation between 2 D code information and the respective two-dimensional sign indicating number picture node automatically.By said method and system, the user need not to utilize other terminal to take or scan to obtain relevant 2 D code information, but can directly can obtain relevant 2 D code information by this browser, and is convenient for users.Persons skilled in the art any not creative transformation of doing under this design philosophy all should be considered as within protection scope of the present invention.