CN104536751B - Webpage source code moving method and device - Google Patents
Webpage source code moving method and device Download PDFInfo
- Publication number
- CN104536751B CN104536751B CN201410829317.6A CN201410829317A CN104536751B CN 104536751 B CN104536751 B CN 104536751B CN 201410829317 A CN201410829317 A CN 201410829317A CN 104536751 B CN104536751 B CN 104536751B
- Authority
- CN
- China
- Prior art keywords
- code
- regular expression
- source code
- webpage source
- migration
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Stored Programmes (AREA)
Abstract
The disclosure discloses a kind of webpage source code moving method and device, belongs to Internet technical field.Methods described includes:Migration instruction is received, the migration instruction is used to ask by first version to migrate the programming language of the webpage source code of target web to the second edition;Obtain the webpage source code of the target web;The programming language of the webpage source code is automatically migrated to the second edition by the first version.Solve the problems, such as to need developer to write the webpage source code of website again using HTML5 in correlation technique;The effect of the transport efficiency for the programming language that can improve webpage source code is reached.
Description
Technical field
This disclosure relates to Internet technical field, more particularly to a kind of webpage source code moving method and device.
Background technology
With the day of HTML5 (Hyper Text Mark-up Language 5, HTML the 5th edition) technology
Benefit is perfect, and increasing developer begins to use HTML5 to develop website.
However, for the existing website developed using HTML4, in order that obtaining the programming language of the webpage source code of the website
It can be migrated by HTML4 to HTML5, developer needs to use HTML5 to write the webpage source code of the website again.
The content of the invention
Present disclose provides a kind of webpage source code moving method and device.The technical scheme is as follows:
According to the first aspect of the embodiment of the present disclosure, there is provided a kind of webpage source code moving method, including:
Migration instruction is received, migration instruction is used to ask the programming language of the webpage source code of target web by first version
Migrate to the second edition;
Obtain the webpage source code of target web;
The programming language of webpage source code is automatically migrated to the second edition by first version.
Alternatively, the programming language of webpage source code is automatically migrated to the second edition by first version, including:
By default first regular expression to removing the generation outside the code segment corresponding to property value in webpage source code
Code section is matched;
If the matching result corresponding to the first regular expression is the first initial code section, the first regular expression is obtained
The first corresponding migration code segment in the second edition;
The first initial code section is replaced using the first migration code segment.
Alternatively, the first regular expression includes the regular expression for match statement code segment, and statement code segment is
Code segment for the version of the programming language of stating webpage source code.
Alternatively, the programming language of webpage source code is automatically migrated to the second edition by first version, including:
The code segment corresponding to property value in webpage source code is matched by default second regular expression;
If the matching result corresponding to the second regular expression is property value, the second regular expression is obtained in the second edition
Corresponding code building form in this, according to property value and code building form generation the second migration code segment;
Determine the second initial code section corresponding to property value in webpage source code;
The second initial code section is replaced using the second migration code segment.
Alternatively, the second regular expression includes at least one of following expression:
For matching the regular expression of the label abandoned by the second edition;
For matching the regular expression of the attribute abandoned by the second edition;
For match renewal label regular expression, renewal label for webpage source code each label in expression way with
The different label of the expression way of corresponding label in the second edition;
For matching the regular expression of not closed label;
For the regular expression for the tag name for matching capitalization;
For matching the regular expression for the attribute not included by quotation marks.
Alternatively, method also includes:
Each self-defined regular expression and each the code building form corresponding to self-defined regular expression are obtained,
Self-defined regular expression is used for the code segment for matching the user-defined format in webpage source code;
The code segment of user-defined format in webpage source code is matched by each self-defined regular expression;
For any self-defined regular expression, if the matching result corresponding to self-defined regular expression is attribute
Value, then the code building form generation the 3rd according to corresponding to property value and self-defined regular expression migrate code segment;
Determine the 3rd initial code section of the property value in webpage source code corresponding to self-defined regular expression;
The 3rd initial code section is replaced using the 3rd migration code segment.
According to the second aspect of the embodiment of the present disclosure, there is provided a kind of webpage source code moving apparatus, including:
Command reception module, it is configured as receiving migration instruction, migration instruction is used to ask the web page source of target web
The programming language of code is migrated to the second edition by first version;
Source code acquisition module, it is configured as obtaining the webpage source code of target web;
Transferring module, be configured as the programming language of webpage source code that gets source code acquisition module by first version from
Moving moves to the second edition.
Alternatively, the transferring module, including:
First matched sub-block, it is configured as by default first regular expression to removing property value in webpage source code
Code segment outside corresponding code segment is matched;
First acquisition submodule, the matching result being configured as in the first matching module are corresponding to the first regular expression
Matching result when being the first initial code section, obtain the first regular expression the first migration generation corresponding in the second edition
Code section;
First replaces submodule, is configured with the first migration code segment and replaces the first initial code section.
Alternatively, the first regular expression includes the regular expression for match statement code segment, and statement code segment is
Code segment for the version of the programming language of stating webpage source code.
Alternatively, the transferring module, including:
Second matched sub-block, it is right to property value institute in webpage source code by default second regular expression to be configured as
The code segment answered is matched;
Migrate code segment generation submodule, be configured as the second matched sub-block matching result be corresponding to second just
When then the matching result of expression formula is property value, the second regular expression code building lattice corresponding in the second edition are obtained
Formula, according to property value and code building form generation the second migration code segment;
Initial code section determination sub-module, the second initial code corresponding to property value is configured to determine that in webpage source code
Section;
Second replaces submodule, is configured with the second migration code segment and replaces the second initial code section.
Alternatively, second regular expression includes at least one of following expression:
For matching the regular expression of the label abandoned by the second edition;
For matching the regular expression of the attribute abandoned by the second edition;
For match renewal label regular expression, renewal label for webpage source code each label in expression way with
The different label of the expression way of corresponding label in the second edition;
For matching the regular expression of not closed label;
For the regular expression for the tag name for matching capitalization;
For matching the regular expression for the attribute not included by quotation marks.
Alternatively, the device also includes:
Data obtaining module, it is configured as obtaining each self-defined regular expression and each self-defined regular expression
Corresponding code building form, self-defined regular expression are used for the code segment for matching the user-defined format in webpage source code;
Source code matching module, it is configured as by each self-defined regular expression to user-defined format in webpage source code
Code segment is matched;
Code segment generation module is migrated, is configured as any self-defined regular expression, if corresponding to self-defined
The matching result of regular expression is property value, then the code building according to corresponding to property value and self-defined regular expression
The migration code segment of form generation the 3rd;
Initial code section determining module, it is configured to determine that the attribute for corresponding to self-defined regular expression in webpage source code
3rd initial code section of value;
Code segment replacement module, it is configured with the 3rd migration code segment and replaces the 3rd initial code section.
According to the third aspect of the embodiment of the present disclosure, there is provided a kind of webpage source code moving apparatus, including:
Processor;
For storing the memory of processor-executable instruction;
Wherein, processor is configured as:
Migration instruction is received, migration instruction is used to ask the programming language of the webpage source code of target web by first version
Migrate to the second edition;
Obtain the webpage source code of target web;
The programming language of webpage source code is automatically migrated to the second edition by first version.
The technical scheme provided by this disclosed embodiment can include the following benefits:
By when receiving migration instruction, obtaining the webpage source code of target web, and by the programming language of the webpage source code
Speech is migrated to the second edition by first version;Solves the webpage for needing developer using HTML5 to website in correlation technique
The problem of source code is write again;The effect of the transport efficiency for the programming language that can improve webpage source code is reached.Meanwhile
Mistake is write due to being easy to occur in developer again compiling procedure, so above-mentioned webpage source code moving method also improves
Accuracy rate in transition process.
It should be appreciated that the general description and following detailed description of the above are only exemplary, this can not be limited
It is open.
Brief description of the drawings
Accompanying drawing herein is merged in specification and forms the part of this specification, shows the implementation for meeting the present invention
Example, and in specification together for explaining principle of the invention.
Fig. 1 is a kind of flow chart of webpage source code moving method according to an exemplary embodiment.
Fig. 2 is a kind of flow chart of webpage source code moving method according to another exemplary embodiment.
Fig. 3 A are a kind of flow charts of webpage source code moving method according to another exemplary embodiment.
Fig. 3 B be according to another exemplary embodiment by self-defined regular expression to webpage source code carry out
Match somebody with somebody and then realize the flow chart of the migration of the programming language of webpage source code.
Fig. 4 is a kind of block diagram of webpage source code moving apparatus according to an exemplary embodiment.
Fig. 5 A are a kind of block diagrams of webpage source code moving apparatus according to another exemplary embodiment.
Fig. 5 B are a kind of block diagrams of the transferring module according to another exemplary embodiment.
Fig. 5 C are another block diagrams of the transferring module according to another exemplary embodiment.
Fig. 6 is a kind of block diagram for being used to migrate the device of webpage source code according to an exemplary embodiment.
Embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following description is related to
During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment
Described in embodiment do not represent and the consistent all embodiments of the present invention.On the contrary, they be only with it is such as appended
The example of the consistent apparatus and method of some aspects being described in detail in claims, of the invention.
Fig. 1 is a kind of flow chart of webpage source code moving method according to an exemplary embodiment, as shown in figure 1,
The webpage source code moving method may comprise steps of.
In a step 101, migration instruction is received, migration instruction is used to ask the programming language of the webpage source code of target web
Speech is migrated to the second edition by first version.
Under normal circumstances, first version is less than the second edition.Certain first version can also be higher than the second edition.
In a step 102, the webpage source code of target web is obtained.
In step 103, the programming language of webpage source code is automatically migrated to the second edition by first version.
In summary, the webpage source code moving method provided in the embodiment of the present disclosure, by receive migration instruction when,
The webpage source code of target web is obtained, and the programming language of the webpage source code is migrated to the second edition by first version;Solve
The problem of needing the developer to be write again to the webpage source code of website using HTML5 in correlation technique;Having reached can
To improve the effect of the transport efficiency of the programming language of webpage source code.Simultaneously as developer holds in compiling procedure very much again
Easily occur and write mistake, so above-mentioned webpage source code moving method also improves the accuracy rate in transition process.
In step 103, migration terminal can realize the volume of webpage source code by the possible migration pattern of the following two kinds
Cheng Yuyan migration:
The first, by default first regular expression in webpage source code remove property value corresponding to code segment it
Outer code segment is matched, and the migration of the programming language of webpage source code is realized according to matching result.
Second, by default second regular expression to the code segment progress corresponding to property value in webpage source code
Match somebody with somebody, the migration of the programming language of webpage source code is realized according to matching result.
So following above-mentioned two situations will be introduced in both embodiments.
Fig. 2 is a kind of flow chart of webpage source code moving method according to an exemplary embodiment, the present embodiment with
The migration of webpage source code is realized to illustrate by the first above-mentioned implementation.As shown in Fig. 2 the webpage source code migrates
Method may comprise steps of.
In step 201, migration instruction is received, migration instruction is used to ask the programming language of the webpage source code of target web
Speech is migrated to the second edition by first version.
When developer wants by first version to migrate the programming language of the webpage source code of a certain webpage to the second edition
When, developer can apply migration instruction in terminal is migrated, and migration terminal receives migration instruction accordingly.
Under normal circumstances, first version is less than the second edition.And first version can be HTML4, the second edition can be
HTML5.Alternatively, first version can also be higher than the second edition, such as, first version HTML5, and the second edition is
HTML4, the present embodiment are not limited this.
Migration terminal refers to the terminal of the migration of the programming language for realizing webpage source code.Alternatively, can in the terminal
There is the application program for realizing the migration of the programming language of webpage source code with operation, the present embodiment is not limited this.
In step 202, the webpage source code of target web is obtained.
When the webpage source code of each webpage is stored in migration terminal, migration terminal can directly read the target of storage
The webpage source code of webpage.Migration terminal can read the storage catalogue for the html file for depositing each webpage, according to storage catalogue
Read the html file of target web.
When the webpage source code of each webpage stores in the server, migration terminal can send acquisition request target web
The acquisition of webpage source code ask to server;Server is inquired about after receiving acquisition request and returns to the webpage of target web
Source code;Migrate the webpage source code for the target web that terminal the reception server returns.
In step 203, by default first regular expression to removing the generation corresponding to property value in webpage source code
Code segment outside code section is matched.
After migration terminal gets the webpage source code of target web, migration terminal can pass through default first canonical
Expression formula matches to removing the code segment outside the code segment corresponding to property value in webpage source code.First regular expression
Including the regular expression for match statement code segment.
Such as by first version be HTML4 exemplified by, migration terminal can by default first regular expression '<!
DOCTYPE.*/>' webpage source code is matched.
Statement code segment is the code segment for stating the version of the programming language of webpage source code.
For example with the webpage source code it is to be come using the HTML4 of the first version webpage source codes write for example, the webpage
Statement code segment in source code can be '<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">', or, '<!DOCTYPE HTML PUBLIC"-//W3C//
DTD HTML 4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">', or,
‘<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01Frameset//EN""http://www.w3.org/
TR/html4/frameset.dtd">’.Certainly, the statement code segment there is likely to be other statement forms, the present embodiment pair
This is not limited.
In step 204, if the matching result corresponding to the first regular expression is the first initial code section, is obtained
One regular expression the first migration code segment corresponding in the second edition.
If migration terminal matches knot corresponding to being obtained after being matched by the first regular expression to webpage source code
Fruit, and the matching result is the first initial code section, then first regular expression can be obtained in the second edition by migrating terminal
In corresponding the first migration code segment.
Migration terminal prestores the first regular expression and first regular expression moving corresponding in the second edition
The corresponding relation moved between code segment, so being the in the matching result that migration terminal is obtained by the first matching regular expressions
During one initial code section, migration terminal can inquire about the migration code corresponding to the first regular expression in the corresponding relation
Section, and the migration code segment inquired is defined as the first migration code segment.
Such as by the second edition be HTML5 exemplified by, migration terminal by '<!DOCTYPE.*/>' webpage source code is entered
Row matching after, migration terminal coupling obtain '<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">', now migrating terminal can be in the corresponding relation to prestore
Inquiry '<!DOCTYPE.*/>' corresponding to first migration code segment, as inquiry obtain '<!DOCTYPE html>’.
In step 205, the first initial code section is replaced using the first migration code segment.
Migration terminal replaces the first initial code section in webpage source code using the first migration code segment got.
Such as in the example above, migration terminal can use '<!DOCTYPE html>' replace in webpage source code
‘<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/
strict.dtd">’。
It should be noted is that when first version is HTML5, and the second edition is HTML4, migration terminal can use
Similar method carries out the migration of the programming language of webpage source code.
Need to illustrate on the other hand, the present embodiment simply with by the first regular expression come match statement code segment come
For example, alternatively, when the code segment that other do not include property value in webpage source code also be present, migration terminal can use
Similar method carries out the migration of the programming language of webpage source code, and the present embodiment will not be repeated here.
In summary, the webpage source code moving method provided in the embodiment of the present disclosure, by receive migration instruction when,
The webpage source code of target web is obtained, and the programming language of the webpage source code is migrated to the second edition by first version;Solve
The problem of needing the developer to be write again to the webpage source code of website using HTML5 in correlation technique;Having reached can
To improve the effect of the transport efficiency of the programming language of webpage source code.Simultaneously as developer holds in compiling procedure very much again
Easily occur and write mistake, so above-mentioned webpage source code moving method also improves the accuracy rate in transition process.
The present embodiment directly can replace first in first version using the second migration code segment in the second edition
Initial code section, centre carry out writing work without developer, improve the transport efficiency of the programming language of webpage source code, drop
The low workload of developer.
Fig. 3 A are a kind of flow charts of webpage source code moving method according to an exemplary embodiment, the present embodiment with
The migration of the programming language of webpage source code is realized to illustrate by above-mentioned second possible implementation.Such as Fig. 3 A institutes
Show, the webpage source code moving method may comprise steps of.
In step 301, migration instruction is received, migration instruction is used to ask the programming language of the webpage source code of target web
Speech is migrated to the second edition by first version.
When developer wants by first version to migrate the programming language of the webpage source code of a certain webpage to the second edition
When, developer can apply migration instruction in terminal is migrated, and migration terminal receives migration instruction accordingly.
First version is less than the second edition under normal circumstances.And first version can be HTML4, the second edition can be
HTML5.Alternatively, first version can also be higher than the second edition, such as, first version HTML5, and the second edition is
HTML4, the present embodiment are not limited this.
Migration terminal refers to the terminal of the migration of the programming language for realizing webpage source code.Alternatively, can in the terminal
There is the application program for realizing the migration of the programming language of webpage source code with operation, the present embodiment is not limited this.
In step 302, the webpage source code of target web is obtained.
When the webpage source code of each webpage is stored in migration terminal, migration terminal can directly read the target of storage
The webpage source code of webpage.Migration terminal can read the storage catalogue for the html file for depositing each webpage, according to storage catalogue
Read the html file of target web.
When the webpage source code of each webpage stores in the server, migration terminal can send acquisition request target web
The acquisition of webpage source code ask to server;Server is inquired about after receiving acquisition request and returns to the webpage of target web
Source code;Migrate the webpage source code for the target web that terminal the reception server returns.
In step 303, by default second regular expression to the code segment corresponding to property value in webpage source code
Matched.
After migration terminal gets the webpage source code of target web, migration terminal can pass through default second canonical
Expression formula matches to the code segment corresponding to property value in webpage source code.Wherein, the second regular expression includes such as following table
Up at least one of formula:
For matching the regular expression of the label abandoned by the second edition;
For matching the regular expression of the attribute abandoned by the second edition;
For matching the regular expression of renewal label, renewal mark s label are expression way in each label of webpage source code
The label different from the expression way of the corresponding label in the second edition;
For matching the regular expression of not closed label;
For the regular expression for the tag name for matching capitalization;
For matching the regular expression for the attribute not included by quotation marks.
Alternatively, it is that HTML5 comes for example, this step can include by HTML4 and the second edition of first version:
(1), when the second regular expression includes being used to match the regular expression of the label abandoned by the second edition, lead to
Cross and webpage source code is matched for matching the regular expression of the label abandoned by the second edition.
Such as second regular expression can include being used to match what is abandoned by HTML5 in HTML4 webpage source code<
basefont>The regular expression of label, second regular expression can be '<Basefont (s+ (color=(.+)|
Size=(d+) | face=(.+)))*\s*/>’.
Above-mentioned is including outcast for matching with the second regular expression<basefont>Label come for example,
Alternatively, the second regular expression can also include outcast for matching<big></big>、<center></center>、
<font></font>Or the regular expression of other labels, the present embodiment are not limited this.
(2), when the second regular expression includes being used to match the regular expression of the attribute abandoned by the second edition, lead to
Cross and webpage source code is matched for matching the regular expression of the attribute abandoned by the second edition.
Such as second regular expression include being used to match what is abandoned by HTML5 in HTML4 webpage source code<body>'s
The regular expression of attribute, second regular expression can be '<Body (s+ (link=(.+) | vlink=(.+)|
Text=(.+) | alink=(.+)))*\s*/>’.
It is above-mentioned simply to include being used to match with the second regular expression<body>Abandonment attribute come for example, optional
Ground, the second regular expression can also include be used for match by HTML5 abandon align, border, bgcolor or other
Attribute, the present embodiment are not limited this.
(3), when the second regular expression includes being used to match the regular expression of renewal label, by for matching more
The regular expression of new label matches to webpage source code;Update label for webpage source code each label in expression way with
The different label of the expression way of corresponding label in the second edition.
For example represent that the label on head can be including following several in HTML4:<Div id=" head ">Head</div
>、<Div id=" hd ">Head</div>、<Div id=" top ">Head</div>、<Div class=" head ">Head
</div>、<Div class=" hd ">Head</div>With<Div class=" top ">Head</div>;And table in HTML5
The label for showing head is<header>Head</header>, both expression ways are otherwise varied, so the second regular expression can
With including for match it is above-mentioned it is several be used for represent head label '<div.*(id=" head " | id=" hd " | id="
Top " | class=" head " | class=" hd " | class=" top ") .*>.*</di v>’.
According to the difference of the expression way of label in HTML4, the regular expression for matching such label can also be set
Difference is set to, the present embodiment is not limited this.And such regular expression is by the webpage to existing a large amount of webpages
Source code carry out semantization analysis, statistics obtain representing semantic various possible expression ways of the same race after, for it is various can
Can expression way and the regular expression that sets.
(4), when the second regular expression include be used for match not closed label regular expression when, by for
Regular expression with not closed label matches to webpage source code.
Because HTML5 requires that all labels must close, and there may be not closed label in HTML4, so
Migrate terminal can be by matching for the regular expression of label not closed in pair net page source code to webpage source code.
Alternatively, some labels are self-closing label in the webpage source code in HTML5 and some labels are complete closure mark
Label, so can set different regular expressions respectively for the label of above two type, the present embodiment is not done to this
Limit.
(5), when the second regular expression include be used for match capitalization tag name regular expression when, by for
The regular expression of tag name with capitalization matches to webpage source code.
Wherein, the second regular expression can include being used for the regular expression for matching all tag names, or, including with
In the regular expression of the tag name of matching capitalization, according to different application scenarios, the second regular expression could be arranged to not
Together.
(6), when the second regular expression includes being used to match the regular expression for the attribute not included by quotation marks, pass through
Regular expression for matching the attribute not included by quotation marks matches to webpage source code.
Second regular expression can include being used for the regular expression for matching each label.Pass through in migration terminal above-mentioned
After regular expression matches to webpage source code, migration terminal can be sentenced by matching obtained attribute-name and property value
Whether disconnected property value is included by quotation marks.
It should be noted that the present embodiment simply using the second regular expression as it is above-mentioned it is several come for example, alternatively,
Second regular expression can also include other possible implementations, and the present embodiment is not limited this.
In step 304, if the matching result corresponding to the second regular expression is property value, the second canonical table is obtained
The code building form corresponding in the second edition up to formula, according to property value and the migration generation of code building form generation second
Code section.
After migration terminal is matched by the second regular expression to webpage source code, when corresponding to the second canonical table
When matching result up to formula is property value, migration terminal can obtain the second regular expression generation corresponding in the second edition
Code generation form, then according to the obtained property value of matching and the code building form acquired generation the second migration code
Section.
It can be stored between each second regular expression and each self-corresponding code building form in migration terminal
Corresponding relation, so, after migration terminal is matched by the second regular expression to webpage source code, when corresponding to this
When the matching result of two regular expressions is property value, migration terminal can inquire about second canonical in the corresponding relation to prestore
Code building form corresponding to expression formula.
Such as using the second regular expression as '<Basefont (s+ (color=(.+) | size=(d+) | face=
(.+)))*\s*/>', and in webpage source code<basefont>For '<Basefont color=" red " size=" 5 "
Face=" courier, serif "/>' exemplified by, after migration terminal is matched by the regular expression to webpage source code,
Migration terminal can match to obtain property value ' red ', ' 5 ' and ' courier, serif '.And migration terminal is in corresponding relation
Inquiring about the code building form corresponding to the obtained regular expression is:
Then, following migration generation can be generated according to obtained property value and above-mentioned code building form is matched by migrating terminal
Code section:
The migration code segment of generation is defined as the second migration code segment by migration terminal.
In step 305, the second initial code section corresponding to property value in webpage source code is determined.
Migration terminal can also determine the second initial code section in webpage source code corresponding to property value.
Such as using property value as ' red ', ' 5 ' and ' courier, serif ' exemplified by, migration terminal can determine to obtain
The second initial code section corresponding to property value for '<Basefont color=" red " size=" 5 " face=" courier,
serif"/>’。
Within step 306, the second initial code section is replaced using the second migration code segment.
Migrating terminal can use the second migration code segment to replace the second initial code section.
For example in the example above, migration terminal can use
Come replace in webpage source code '<Basefont color=" red " size=" 5 " face=" courier,
serif"/>’。
In summary, the webpage source code moving method provided in the embodiment of the present disclosure, by receive migration instruction when,
The webpage source code of target web is obtained, and the programming language of the webpage source code is migrated to the second edition by first version;Solve
The problem of needing the developer to be write again to the webpage source code of website using HTML5 in correlation technique;Having reached can
To improve the effect of the transport efficiency of the programming language of webpage source code.Simultaneously as developer holds in compiling procedure very much again
Easily occur and write mistake, so above-mentioned webpage source code moving method also improves the accuracy rate in transition process.
Require supplementation with explanation is a bit, above-described embodiment simply with use respectively default first regular expression or
Default second regular expression is come exemplified by realizing the migration of the programming language of webpage source code, and alternatively, migration terminal can be with
Simultaneously the migration of the programming language of webpage source code, the present embodiment are carried out using the first regular expression and the second regular expression
This is not limited.Also, migrate terminal using one of regular expression to be migrated when, developer may be used also
Other code segments in a manner of manually changing in the modification webpage source code of adaptability.For example migration terminal passes through Fig. 3 A
In webpage source code moving method migrated, and moved by way of the statement code segment for receiving developer's manual modification
Statement code segment is moved, the present embodiment is not limited this.
Require supplementation with explanation on the other hand, the code of user-defined format is there may be in the webpage source code of some webpages
Section, now, after being migrated by the first regular expression or the second regular expression to the programming language of webpage source code,
May can also there is the code segment not being migrated.In order to be migrated to the code segment of these user-defined formats, developer is also
Can according to the particular content of the webpage source code of target web self-defined regular expression, pass through customized regular expression
To realize the migration of the code segment of these user-defined formats.So refer to Fig. 3 B, above-mentioned webpage source code moving method can be with
Including:
In step 307, obtain corresponding to each self-defined regular expression and each self-defined regular expression
Code building form, self-defined regular expression are used for the code segment for matching the user-defined format in webpage source code.
Migration terminal can receive the self-defined regular expression of developer's setting, can also be obtained from other-end
The self-defined regular expression that developer is set.
Meanwhile migration terminal can also obtain the code building form corresponding to each self-defined regular expression.Migration
Terminal can receive the code building form that developer is set for each self-defined regular expression, or from other-end
Obtain the code building form corresponding to each self-defined regular expression.
In step 308, the code segment of user-defined format in webpage source code is entered by each self-defined regular expression
Row matching.
In a step 309, for any self-defined regular expression, if the matching corresponding to self-defined regular expression
As a result be property value, then the migration of code building form generation the 3rd according to corresponding to property value and self-defined regular expression
Code segment.
In the step 310, the 3rd initial generation of the property value in webpage source code corresponding to self-defined regular expression is determined
Code section.
In step 311, the 3rd initial code section is replaced using the 3rd migration code segment.
Wherein step 308 is similar to step 306 with the step 303 in above-described embodiment to step 311, unlike, step
The customized regular expression of developer is used in rapid 308, and the migration default regular expressions of terminal are used in step 303
Formula, the present embodiment will not be repeated here.
It should be noted that step 307 can perform in any one step in above-mentioned each embodiment, and in step
307 before step 203 or step 303 when performing, and migration terminal can preferentially perform step 308 and then perform step 203
Or step 303, the present embodiment are not limited this.
Following is embodiment of the present disclosure, can be used for performing embodiments of the present disclosure.It is real for disclosure device
The details not disclosed in example is applied, refer to embodiments of the present disclosure.
Fig. 4 is a kind of block diagram of webpage source code moving apparatus according to an exemplary embodiment, as shown in figure 4, should
Webpage source code moving apparatus can include but is not limited to:Command reception module 410, source code acquisition module 420 and transferring module
430。
Command reception module 410, it is configured as receiving migration instruction, migration instruction is used to ask the webpage of target web
The programming language of source code is migrated to the second edition by first version;
Source code acquisition module 420, it is configured as obtaining the webpage source code of target web;
Transferring module 430, the programming language for the webpage source code for being configured as getting source code acquisition module 420 is by first
Version is automatically migrated to the second edition.
In summary, the webpage source code moving apparatus provided in the embodiment of the present disclosure, by receive migration instruction when,
The webpage source code of target web is obtained, and the programming language of the webpage source code is migrated to the second edition by first version;Solve
The problem of needing the developer to be write again to the webpage source code of website using HTML5 in correlation technique;Having reached can
To improve the effect of the transport efficiency of the programming language of webpage source code.Simultaneously as developer holds in compiling procedure very much again
Easily occur and write mistake, so above-mentioned webpage source code moving method also improves the accuracy rate in transition process.
Fig. 5 A are a kind of block diagrams of webpage source code moving apparatus according to an exemplary embodiment, as shown in Figure 5A,
The webpage source code moving apparatus can include but is not limited to:Command reception module 510, source code acquisition module 520 and transferring module
530。
Command reception module 510, it is configured as receiving migration instruction, migration instruction is used to ask the webpage of target web
The programming language of source code is migrated to the second edition by first version;
Source code acquisition module 520, it is configured as obtaining the webpage source code of target web;
Transferring module 530, the programming language for the webpage source code for being configured as getting source code acquisition module 520 is by first
Version is automatically migrated to the second edition.
Alternatively, it refer to Fig. 5 B, transferring module 530, including:
First matched sub-block 531, it is configured as to removing in webpage source code belonging to by default first regular expression
The code segment outside code segment corresponding to property value is matched;
First acquisition submodule 532, the matching result being configured as in the first matching module 531 are corresponding to the first canonical
When the matching result of expression formula is the first initial code section, first of the first regular expression corresponding in the second edition is obtained
Migrate code segment;
First replaces submodule 533, is configured with the first migration code segment and replaces the first initial code section.
Alternatively, the first regular expression includes the regular expression for match statement code segment, and statement code segment is
Code segment for the version of the programming language of stating webpage source code.
Alternatively, it refer to Fig. 5 C, transferring module 530, including:
Second matched sub-block 534, it is configured as by default second regular expression to property value in webpage source code
Corresponding code segment is matched;
Code segment generation submodule 535 is migrated, the matching result being configured as in the second matched sub-block is corresponding to the
When the matching result of two regular expressions is property value, the code life corresponding in the second edition of the second regular expression is obtained
Into form, according to property value and code building form generation the second migration code segment;
Initial code section determination sub-module 536, it is configured to determine that in webpage source code that second corresponding to property value is initial
Code segment;
Second replaces submodule 537, is configured with the second migration code segment and replaces the second initial code section.
Alternatively, the second regular expression includes at least one of following expression:
For matching the regular expression of the label abandoned by the second edition;
For matching the regular expression of the attribute abandoned by the second edition;
For match renewal label regular expression, renewal label for webpage source code each label in expression way with
The different label of the expression way of corresponding label in the second edition;
For matching the regular expression of not closed label;
For the regular expression for the tag name for matching capitalization;
For matching the regular expression for the attribute not included by quotation marks.
Alternatively, device also includes:
Data obtaining module 540, it is configured as obtaining each self-defined regular expression and each self-defined canonical table
Up to the code building form corresponding to formula, self-defined regular expression is used for the code for matching the user-defined format in webpage source code
Section;
Source code matching module 550, it is configured as by each self-defined regular expression to self-defined lattice in webpage source code
The code segment of formula is matched;
Code segment generation module 560 is migrated, is configured as any self-defined regular expression, is made by oneself if corresponding to
The matching result of adopted regular expression is property value, then the code life according to corresponding to property value and self-defined regular expression
Into the migration code segment of form generation the 3rd;
Initial code section determining module 570, it is configured to determine that in webpage source code corresponding to self-defined regular expression
3rd initial code section of property value;
Code segment replacement module 580, it is configured with the 3rd migration code segment and replaces the 3rd initial code section.
In summary, the webpage source code moving apparatus provided in the embodiment of the present disclosure, by receive migration instruction when,
The webpage source code of target web is obtained, and the programming language of the webpage source code is migrated to the second edition by first version;Solve
The problem of needing the developer to be write again to the webpage source code of website using HTML5 in correlation technique;Having reached can
To improve the effect of the transport efficiency of the programming language of webpage source code.Simultaneously as developer holds in compiling procedure very much again
Easily occur and write mistake, so above-mentioned webpage source code moving method also improves the accuracy rate in transition process.
On the device in above-described embodiment, wherein modules perform the concrete mode of operation in relevant this method
Embodiment in be described in detail, explanation will be not set forth in detail herein.
Fig. 6 is a kind of block diagram for being used to migrate the device 600 of webpage source code according to an exemplary embodiment.Example
Such as, device 600 may be provided in a server or terminal.Reference picture 6, device 600 include processing component 622, and it enters one
Step includes one or more processors, and as the memory resource representated by memory 632, can be by processing component for storing
622 instructions performed, such as application program.The application program stored in memory 632 can include one or more
Each corresponds to the module of one group of instruction.In addition, processing component 622 is configured as execute instruction, obtained with performing above- mentioned information
Take method.
Device 600 can also include the power management that a power supply module 626 is configured as performs device 600, and one has
Line or radio network interface 650 are configured as device 600 being connected to network, and input and output (I/O) interface 658.Dress
Putting 600 can operate based on the operating system for being stored in memory 632, such as Windows ServerTM, Mac OS XTM,
UnixTM, LinuxTM, FreeBSDTM or similar.
It should be appreciated that the invention is not limited in the precision architecture for being described above and being shown in the drawings, and
And various modifications and changes can be being carried out without departing from the scope.The scope of the present invention is only limited by appended claim.
Claims (9)
- A kind of 1. webpage source code moving method, it is characterised in that including:Migration instruction is received, the migration instruction is used to ask the programming language of the webpage source code of target web by first version Migrate to the second edition;Obtain the webpage source code of the target web;The programming language of the webpage source code is automatically migrated to the second edition by the first version,The programming language by the webpage source code is automatically migrated to the second edition by the first version, including:By default first regular expression to removing the generation outside the code segment corresponding to property value in the webpage source code Code section is matched;If the matching result corresponding to first regular expression is the first initial code section, the first canonical table is obtained The first migration code segment corresponding in the second edition up to formula;The first initial code section is replaced using the described first migration code segment;Each self-defined regular expression and each the code building form corresponding to self-defined regular expression are obtained, it is described Self-defined regular expression is used for the code segment for matching the user-defined format in the webpage source code;Pass through code segment progress of each self-defined regular expression to user-defined format described in the webpage source code Match somebody with somebody;For any described self-defined regular expression, if the matching result corresponding to the self-defined regular expression is category Property value, then according to corresponding to the property value and the self-defined regular expression code building form generation the 3rd migration Code segment;Determine the 3rd initial code section of the property value in the webpage source code corresponding to the self-defined regular expression;The 3rd initial code section is replaced using the described 3rd migration code segment.
- 2. according to the method for claim 1, it is characterised in that first regular expression includes being used for match statement generation The regular expression of code section, the statement code segment are the codes for stating the version of the programming language of the webpage source code Section.
- 3. according to the method for claim 1, it is characterised in that the programming language by the webpage source code is by described the One version is automatically migrated to the second edition, including:The code segment corresponding to property value in the webpage source code is matched by default second regular expression;If the matching result corresponding to second regular expression is property value, second regular expression is obtained in institute Code building form corresponding in the second edition is stated, is moved according to the property value and code building form generation second Move code segment;Determine the second initial code section corresponding to property value described in the webpage source code;The second initial code section is replaced using the described second migration code segment.
- 4. according to the method for claim 3, it is characterised in that second regular expression is included in following expression It is at least one:For matching the regular expression of the label abandoned by the second edition;For matching the regular expression of the attribute abandoned by the second edition;For matching the regular expression of renewal label, the renewal label is expression side in each label of the webpage source code The formula label different from the expression way of the corresponding label in the second edition;For matching the regular expression of not closed label;For the regular expression for the tag name for matching capitalization;For matching the regular expression for the attribute not included by quotation marks.
- A kind of 5. webpage source code moving apparatus, it is characterised in that including:Command reception module, it is configured as receiving migration instruction, the migration instruction is used to ask the web page source of target web The programming language of code is migrated to the second edition by first version;Source code acquisition module, it is configured as obtaining the webpage source code of the target web;Transferring module, the programming language for the webpage source code for being configured as getting the source code acquisition module is by described One version is automatically migrated to the second edition,The transferring module, including:First matched sub-block, it is configured as by default first regular expression to removing property value in the webpage source code Code segment outside corresponding code segment is matched;First acquisition submodule, the matching result being configured as in first matching module are corresponding to the first canonical table When matching result up to formula is the first initial code section, it is corresponding in the second edition to obtain first regular expression First migration code segment;First replaces submodule, is configured with the first migration code segment and replaces the first initial code section;Data obtaining module, it is configured as obtaining each self-defined regular expression and each self-defined regular expression institute is right The code building form answered, the self-defined regular expression are used for the code for matching the user-defined format in the webpage source code Section;Source code matching module, it is configured as by each self-defined regular expression to self-defined lattice in the webpage source code The code segment of formula is matched;Code segment generation module is migrated, is configured as any described self-defined regular expression, if corresponding to described in certainly The matching result for defining regular expression is property value, then right according to the property value and the self-defined regular expression institute The migration code segment of code building form generation the 3rd answered;Initial code section determining module, it is configured to determine that in the webpage source code corresponding to the self-defined regular expression 3rd initial code section of property value;Code segment replacement module, it is configured with the 3rd migration code segment and replaces the 3rd initial code section.
- 6. device according to claim 5, it is characterised in that first regular expression includes being used for match statement generation The regular expression of code section, the statement code segment are the codes for stating the version of the programming language of the webpage source code Section.
- 7. device according to claim 5, it is characterised in that the transferring module, including:Second matched sub-block, it is right to property value institute in the webpage source code by default second regular expression to be configured as The code segment answered is matched;Code segment generation submodule is migrated, the matching result being configured as in second matched sub-block is corresponding to described the When the matching result of two regular expressions is property value, it is corresponding in the second edition to obtain second regular expression Code building form, according to the property value and the code building form generation second migration code segment;Initial code section determination sub-module, it is configured to determine that described in the webpage source code that second corresponding to property value is initial Code segment;Second replaces submodule, is configured with the second migration code segment and replaces the second initial code section.
- 8. device according to claim 7, it is characterised in that second regular expression is included in following expression It is at least one:For matching the regular expression of the label abandoned by the second edition;For matching the regular expression of the attribute abandoned by the second edition;For matching the regular expression of renewal label, the renewal label is expression side in each label of the webpage source code The formula label different from the expression way of the corresponding label in the second edition;For matching the regular expression of not closed label;For the regular expression for the tag name for matching capitalization;For matching the regular expression for the attribute not included by quotation marks.
- A kind of 9. webpage source code moving apparatus, it is characterised in that including:Processor;For storing the memory of processor-executable instruction;Wherein, the processor is configured as:Migration instruction is received, the migration instruction is used to ask the programming language of the webpage source code of target web by first version Migrate to the second edition;Obtain the webpage source code of the target web;The programming language of the webpage source code is automatically migrated to the second edition by the first version,The programming language by the webpage source code is automatically migrated to the second edition by the first version, including:By default first regular expression to removing the generation outside the code segment corresponding to property value in the webpage source code Code section is matched;If the matching result corresponding to first regular expression is the first initial code section, the first canonical table is obtained The first migration code segment corresponding in the second edition up to formula;The first initial code section is replaced using the described first migration code segment,The processor is additionally configured to:Each self-defined regular expression and each the code building form corresponding to self-defined regular expression are obtained, it is described Self-defined regular expression is used for the code segment for matching the user-defined format in the webpage source code;Pass through code segment progress of each self-defined regular expression to user-defined format described in the webpage source code Match somebody with somebody;For any described self-defined regular expression, if the matching result corresponding to the self-defined regular expression is category Property value, then according to corresponding to the property value and the self-defined regular expression code building form generation the 3rd migration Code segment;Determine the 3rd initial code section of the property value in the webpage source code corresponding to the self-defined regular expression;The 3rd initial code section is replaced using the described 3rd migration code segment.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410829317.6A CN104536751B (en) | 2014-12-26 | 2014-12-26 | Webpage source code moving method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410829317.6A CN104536751B (en) | 2014-12-26 | 2014-12-26 | Webpage source code moving method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104536751A CN104536751A (en) | 2015-04-22 |
CN104536751B true CN104536751B (en) | 2018-04-06 |
Family
ID=52852283
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410829317.6A Active CN104536751B (en) | 2014-12-26 | 2014-12-26 | Webpage source code moving method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104536751B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105912613A (en) * | 2016-04-06 | 2016-08-31 | 江苏中威科技软件系统有限公司 | Website template quick migration method |
JP2018041373A (en) * | 2016-09-09 | 2018-03-15 | オムロン株式会社 | Executable program creation device, executable program creation method, and executable program creation program |
CN108270838B (en) * | 2017-01-04 | 2020-04-24 | 中国科学院声学研究所 | Container-based browser HTML5 resource coordination method |
CN109725927B (en) * | 2018-05-08 | 2023-07-21 | 中国平安人寿保险股份有限公司 | Synchronization method and device of code management system, storage medium and terminal |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1805346A (en) * | 2005-01-13 | 2006-07-19 | 陈翌 | Mobile telephone browser with multiple interpreters |
CN101410812A (en) * | 2006-04-25 | 2009-04-15 | 国际商业机器公司 | Migrating data that is subject to access by input/output devices |
CN101604328A (en) * | 2009-07-06 | 2009-12-16 | 深圳市汇海科技开发有限公司 | A kind of vertical search method for Internet information |
CN102253986A (en) * | 2011-06-30 | 2011-11-23 | 北京新媒传信科技有限公司 | Method and device for improving webpage displaying effect in multiple terminals |
CN102779031A (en) * | 2011-05-10 | 2012-11-14 | 北京磊友信息科技有限公司 | Method for generating JavaScript program |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090100329A1 (en) * | 2007-10-04 | 2009-04-16 | Danny Javier Espinoza | Method of Deploying a Web Widget In a Desktop Widget Platform |
-
2014
- 2014-12-26 CN CN201410829317.6A patent/CN104536751B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1805346A (en) * | 2005-01-13 | 2006-07-19 | 陈翌 | Mobile telephone browser with multiple interpreters |
CN101410812A (en) * | 2006-04-25 | 2009-04-15 | 国际商业机器公司 | Migrating data that is subject to access by input/output devices |
CN101604328A (en) * | 2009-07-06 | 2009-12-16 | 深圳市汇海科技开发有限公司 | A kind of vertical search method for Internet information |
CN102779031A (en) * | 2011-05-10 | 2012-11-14 | 北京磊友信息科技有限公司 | Method for generating JavaScript program |
CN102253986A (en) * | 2011-06-30 | 2011-11-23 | 北京新媒传信科技有限公司 | Method and device for improving webpage displaying effect in multiple terminals |
Also Published As
Publication number | Publication date |
---|---|
CN104536751A (en) | 2015-04-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104536751B (en) | Webpage source code moving method and device | |
US20080028302A1 (en) | Method and apparatus for incrementally updating a web page | |
CN103970750B (en) | A kind of method and apparatus generating html web page | |
US20170124069A1 (en) | Translation Review Workflow Systems and Methods | |
US11023507B2 (en) | Methods and systems for performing a model driven domain specific search | |
US8745027B1 (en) | Jslayout cascading style sheets optimization | |
CN108762743A (en) | Data table operation code generation method and device | |
GB2423387A (en) | Application-Generic Sequence Diagram Generator Driven by a Non-Proprietary Language | |
CN105094836B (en) | It is a kind of to generate the method and apparatus for illustrating document | |
US9817887B2 (en) | Universal text representation with import/export support for various document formats | |
CN102651002A (en) | Webpage information extracting method and system | |
US20140089827A1 (en) | Assisting graphical user interface design | |
CN113051285A (en) | SQL statement conversion method, system, equipment and storage medium | |
CN105446725A (en) | Method and system for model driven development | |
CN103383691A (en) | Webpage online editing method and device | |
CN105446986A (en) | Web page processing method and device | |
CN105824944B (en) | A kind of XML configuration data maintaining method and system based on scripting language | |
CN114138244A (en) | Method and device for automatically generating model files, storage medium and electronic equipment | |
CN115438740A (en) | Multi-source data convergence and fusion method and system | |
US20150113487A1 (en) | Automated integrated circuit design documentation | |
CN106570133A (en) | Method and device for constructing visual webpage information extracting rule | |
CN110275712B (en) | Text replacement method, device and equipment | |
CN109543122B (en) | Content synchronization method, device, storage medium and electronic device | |
US11126410B2 (en) | Method and apparatus for building pages, apparatus and non-volatile computer storage medium | |
Langer et al. | Designing a Lexical Database for a Combined Use of Corpus Annotation and Dictionary Editing |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |