The content of the invention
It is a primary object of the present invention to provide the matching process and device of a kind of resource request, to solve in the prior art
The problem for the treatment of effeciency is low when being matched to resource request.
To achieve these goals, according to an aspect of the invention, there is provided a kind of matching process of resource request, bag
Include:Obtain the feature of resource request;The matched rule corresponding with the feature of resource request in loading rule database, wherein,
Rule database is the database for carrying out classification storage in browser to matched rule;And using the matched rule loaded to money
Source request is matched.
Further, carrying out classification storage to matched rule includes:Receive matched rule;The type of acquisition matched rule,
Action scope and keyword, wherein, action scope is the domain name of the applicable loading website of matched rule, and loading website is loading webpage
The website of resource;Type according to getting is classified to matched rule, and storage class and matched rule and pair of type
It should be related to;Action scope according to getting is classified to matched rule, and memory action domain and matched rule and action scope
Corresponding relation;And matched rule is classified according to the keyword got, and store keyword and matched rule and pass
The corresponding relation of keyword.
Further, the keyword of matched rule is obtained in the following manner:Read the character string for representing matched rule;
First character is often read in reading process, to representing that the character string of matched rule is once split, obtains multiple points
Cut character string, wherein, the first character neither alphabetic character nor numerical character;Count the character amount of each separating character string
Number;And determine the keyword that the most separating character string of character amount is matched rule.
Further, the feature of resource request include initiating the domain of website of resource request, webpage corresponding to resource request
The type of resource and initiate resource request website address information, wherein, in loading rule database with the spy of resource request
Levying corresponding matched rule includes being loaded using at least one of following load mode:With net corresponding to resource request
The type of page resource is as index terms, and according to webpage corresponding with resource request in types index mode loading rule database
The corresponding matched rule of the type of resource, wherein, types index loads according to the type of matched rule to matched rule;
Using initiate resource request website domain as index terms, and according in action scope indexed mode loading rule database with initiation
The corresponding matched rule in the domain of the website of resource request, wherein, effect Domain Index is according to the action scope of matched rule to matching
Rule is loaded;And using initiate resource request website address information as index terms, and according to keyword index side
The matched rule corresponding with the address information of the website of initiation resource request in formula loading rule database, wherein, keyword
Index loads according to the keyword of matched rule to matched rule.
Further, using the type of web page resources corresponding to resource request as index terms, and according to types index mode
In loading rule database with resource request corresponding to the corresponding matched rules of type of web page resources include:Search rule number
According to storehouse whether to be stored with the first kind in judgment rule database, wherein, first kind webpage money corresponding with resource request
The type in source is identical;And if judge to be stored with the first kind in rule database, the first kind in acquisition rule database
The action scope of matched rule under type, obtain the first action scope, using initiate resource request website domain as index terms, and press
Include according to the corresponding matched rule in the domain of the website in action scope indexed mode loading rule database with initiating resource request:
Judge whether include the first domain in the first action scope, wherein, the first domain is the domain for the website for initiating resource request;And if judge
Going out the first action scope includes the first domain, then obtains the keyword for the matched rule for being applied to the first domain in rule database, obtain
To the first keyword, added using initiating the address information of website of resource request as index terms, and according to keyword index mode
Carrying matched rule corresponding with the address information of the website of initiation resource request in rule database includes:Judge the first character
Whether string includes the first keyword, wherein, the first character string is to represent the character string of address information;And if judge the first word
Symbol string includes the first keyword, then the matched rule of the first keyword is included in loading rule database.
Further, before the type, action scope and keyword of matched rule is obtained, matching process also includes:Obtain
The time attribute of the matched rule received;Obtain the time attribute of rule database;And judge the matched rule received
Time attribute at the time of correspond to whether at the time of the time attribute of rule database corresponds to after, wherein, if judging to connect
At the time of the time attribute of the matched rule received corresponds at the time of the time attribute of rule database corresponds to after, then obtain
Type, action scope and the keyword of matched rule.
To achieve these goals, according to another aspect of the present invention, there is provided a kind of coalignment of resource request, should
Coalignment is used to perform any matching process that the above of the present invention is provided.
To achieve these goals, according to another aspect of the present invention, there is provided a kind of coalignment of resource request, bag
Include:First acquisition unit, for obtaining the feature of resource request;Loading unit, for being asked in loading rule database with resource
The corresponding matched rule of the feature asked, wherein, rule database is the number for carrying out classification storage in browser to matched rule
According to storehouse;And matching unit, for being matched using the matched rule of loading to resource request.
Further, coalignment also includes:Receiving unit, for receiving matched rule;Second acquisition unit, for obtaining
The type, action scope and keyword of matched rule are taken, wherein, action scope is the domain name of the applicable loading website of matched rule,
Load website of the website for loading web page resources;First processing units, for being carried out according to the type got to matched rule
Classification, and storage class and matched rule and the corresponding relation of type;Second processing unit, for according to the action scope got
Matched rule is classified, and memory action domain and matched rule and the corresponding relation of action scope;And the 3rd processing unit,
For classifying according to the keyword got to matched rule, and it is corresponding with keyword to store keyword and matched rule
Relation.
Further, second acquisition unit includes:Subelement is read, the character string of matched rule is represented for reading;Point
Subelement is cut, for often reading first character in reading process, to representing that the character string of matched rule is carried out once
Segmentation, obtain multiple separating character strings, wherein, the first character neither alphabetic character nor numerical character;Count subelement,
For the number for the character amount for counting each separating character string;And determination subelement, the segmentation most for determining character amount
Character string is the keyword of matched rule.
Further, the feature of resource request include initiating the domain of website of resource request, webpage corresponding to resource request
The type of resource and the address information of the website of initiation resource request, wherein, loading unit includes:First loading subelement, is used
In using the type of web page resources corresponding to resource request as index terms, and according in types index mode loading rule database
With resource request corresponding to web page resources the corresponding matched rule of type, wherein, types index according to matched rule class
Type loads to matched rule;Second loading subelement, the domain for the website to initiate resource request as index terms, and
According in action scope indexed mode loading rule database with the corresponding matched rule in domain for the website for initiating resource request, its
In, effect Domain Index loads according to the action scope of matched rule to matched rule;And the 3rd loading subelement, for
The address information of the website of resource request is initiated as index terms, and according in keyword index mode loading rule database and
Initiate the corresponding matched rule of address information of the website of resource request, wherein, keyword index according to matched rule pass
Keyword loads to matched rule.
Further, the first loading unit includes:First judge module, for search rule database with judgment rule number
Whether the first kind is stored with according in storehouse, wherein, the first kind is identical with the type of web page resources corresponding to resource request;And
First acquisition module, for when being stored with the first kind in judging rule database, obtaining the first kind in rule database
The action scope of matched rule under type, obtains the first action scope, and the second loading unit includes:Second judge module, for judging
Whether include the first domain in first action scope, wherein, the first domain is the domain for the website for initiating resource request;And second obtain mould
Block, the matching for being applied to the first domain in rule database for when judging that the first action scope includes the first domain, obtaining are advised
Keyword then, obtains the first keyword, and the 3rd loading unit includes:3rd judge module, for judging that the first character string is
It is no including the first keyword, wherein, the first character string for represent address information character string;And load-on module, for sentencing
Break when the first character string and including the first keyword, the matched rule of the first keyword is included in loading rule database.
By the present invention, using the feature for obtaining resource request;In loading rule database with the feature phase of resource request
Corresponding matched rule, wherein, rule database is the database for carrying out classification storage in browser to matched rule;And profit
Resource request is matched with the matched rule of loading.By when carrying out rule match to resource request, obtaining rule base
In the rule corresponding with the feature of resource request, realize the matching times for reducing and rule match being carried out to resource request, keep away
Exempt from match caused treatment effeciency by resource request and strictly all rules in rule base successively low, solved prior art
In the problem for the treatment of effeciency is low when being matched to resource request, and then improve the effect of resource request matching efficiency.
Embodiment
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can phase
Mutually combination.Describe the present invention in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
The embodiments of the invention provide a kind of matching process of resource request, the money provided below the embodiment of the present invention
The matching process of source request is specifically introduced:
Fig. 2 is the flow chart of matching process according to embodiments of the present invention, as shown in Fig. 2 this method includes following step
Rapid S201 to step S203:
S201:The feature of resource request is obtained, specifically, when user opens webpage by browser, browser is first
Resource request can be produced, obtains the web page resources corresponding with resource request by being responded to resource request again afterwards,
Wherein, the feature for obtaining resource request be mainly obtain the domain of website for initiating resource request, webpage money corresponding to resource request
The type in source and the address information of the website of initiation resource request.
S202:The matched rule corresponding with the feature of resource request in loading rule database, wherein, rule database
For in browser to matched rule carry out classification storage database, i.e. in loading rule database with the feature of resource request
Matched rule with corresponding relation.
S203:Resource request is matched using the matched rule of loading.Specifically, prior art can be used any
A kind of method that matching treatment is carried out to resource request.
The matching process of the embodiment of the present invention to resource request when carrying out rule match, by being carried out to resource request
During rule match, rule corresponding with the feature of resource request in rule base is obtained, reduction is realized and resource request is carried out
The matching times of rule match, avoid and carry out resource request with strictly all rules in rule base to match caused processing successively
Efficiency is low, treatment effeciency is low when solving the problems, such as in the prior art to match resource request, and then improves money
Ask the effect of matching efficiency in source.
To use character string complete match method in step S203, using the matched rule of loading to resource request progress
With illustration:
First, the character of the character string for obtaining the address information for representing resource request respectively and the matched rule for representing loading
String, wherein, the character string for representing the address information of resource request is the word corresponding to the URL addresses of the website of initiation resource request
Symbol string, the character string for representing the matched rule of loading are the coded string of the matched rule loaded.Wherein, if in step S202
When the matched rule of loading includes a plurality of matched rule, then to representing that the character string of each bar matched rule obtains, obtain
A plurality of character string, one matched rule of a string representation.
Then, judge to represent that the character string of the address information of resource request and the character string of the matched rule of expression loading are
It is no identical, i.e. judge whether the character string of matched rule of the URL address characters string of resource request with representing loading is identical, its
In, if if the matched rule loaded in step S202 is more rules, the character of the address information of resource request will be represented
The each character string gone here and there and got is contrasted identical to judge whether.
Finally, judging to represent the character of matched rule of the character string of the address information of resource request with representing loading
When going here and there identical, determine that the matched rule of resource request and browser matches.If the matched rule loaded in step S202 includes
A plurality of matched rule, then carried out pair by the character string and each character string getting that represent the address information of resource request
After judgement, if judging to represent the character string of the address information of resource request and any character string phase in a plurality of character string
Together, it is determined that the matched rule of resource request and browser matches.
In the embodiment of the present invention to matched rule carry out classification storage specific processing method figure 3 illustrates such as Fig. 3
It is shown:
First, the matched rule in browser is received, type, action scope and the keyword of the matched rule to receiving enter
Row obtains, wherein, the enumeration type of the predetermined coded string of program, institute when so-called type refers to encode matched rule
Meaning action scope refers to that matched rule needs come into force under what domain name, i.e. the domain name of the adaptable loading website of matched rule
The as action scope of the matched rule, so-called loading website refer to the website loaded to web page resources, implemented in the present invention
The website that resource request is initiated in example is a loading website;
Then, store after classifying to matched rule, matched rule classified essentially according to following three kinds of modes,
Mode one:Enumeration type according to getting is classified to matched rule, and store the type that gets and matched rule with
The corresponding relation of type, i.e. be correspondingly stored in each rule in matched rule under the enumeration type of its ownership;Mode two:
Matched rule is classified according to action scope is got, and stores the action scope got and matched rule and pair of action scope
It should be related to, i.e. each rule in matched rule is correspondingly stored under the action scope that it is applied;Mode three:According to acquisition
To keyword matched rule is classified, and store the corresponding relation of keyword and matched rule and keyword, i.e. will
Correspondingly it is stored under corresponding keyword with each rule in rule.
Wherein, in embodiments of the present invention, action scope being divided into two kinds, one kind is specified domain, and one kind is universe, wherein,
When it is any website in preassigned a part of website to load website, matched rule A comes into force, then this part preassigns
The set of the domain name of website is matched rule A specified domain;When loading website whencesoever website, matched rule B is equal
Coming into force, then the set of domains of all websites is matched rule B universe, wherein, the matched rule to be come into force under universe is complete
Domain rule, the matched rule to be come into force under specified domain are specified domain rule.The enumeration type of the embodiment of the present invention includes
enumHTML(Html document resources)、enumCSS(CSS resource)、 enumPicture(Image resource)、enumJS
(Script resource)、enumObject(Embedded object resource)、enumXML (Xml document resource)、enumUndef(Other are uncertain
Adopted type);The keyword of matched rule can be the short character strings in matched rule coded string, i.e. by expression
Character string with rule is split to obtain the keyword of matched rule, and specific dividing method is:To representing matched rule
Character string is read out, and first character is often read in reading process, i.e., to representing that the character string of matched rule is carried out
Once split, obtain multiple separating character strings, wherein, so-called first character refers to the word in addition to alphabetic character and numerical character
Symbol;Then count character in each separating character string number how much;Finally determine that the most separating character string of character number is
The keyword of matched rule, wherein, if there is the character of two or more separating character strings in multiple separating character strings
Number is N, and the character number of other separating character strings is both less than N, i.e. the most segmentation of character number in separating character string
Character string is multiple, it is determined that the character string that any one character number is N is the keyword of matched rule.For example, table
The character string for showing certain matched rule is " abcde-fghij.klmnop.com/qrstuvw.html ", it is determined that " qrstuvw "
For the keyword of this matched rule.
Further, the matching corresponding with the feature of resource request is loaded in the embodiment of the present invention from rule database
Rule includes at least one of in such a way or two kinds are loaded in a manner of two or more combinations:
Mode one:Using the type of web page resources corresponding to resource request as index terms, and add according to types index mode
Carry in rule database with resource request corresponding to web page resources the corresponding matched rule of type, wherein, types index is pressed
Matched rule is loaded according to the type of matched rule, i.e. according to the type of web page resources corresponding to resource request from rule
Loading and the matched rule under the type identical type, have reached and have avoided loading webpage corresponding with resource request in database
The matched rule that the type of resource differs, reduce the loading capacity of matched rule.
Mode two:The domain of website to initiate resource request loads rule as index terms, and according to action scope indexed mode
Then matched rule corresponding with the domain of the website of initiation resource request in database, wherein, effect Domain Index is advised according to matching
Action scope then loads to matched rule, i.e. the domain according to the website for initiating resource request loads from rule database
The matched rule being applied under the domain, the matching for avoiding loading from can not being applied under the domain for the website for initiating resource request is reached
Rule, reduce the loading capacity of matched rule.
Mode three:Using initiate resource request website address information as index terms, and according to keyword index mode
The matched rule corresponding with the address information of the website of initiation resource request in loading rule database, wherein, keyword rope
Draw and matched rule is loaded according to the keyword of matched rule, i.e. loaded according to address information, please with initiating resource
The matched rule that the address information for the website asked is corresponding meets:Represent the matching rule in the character string of address information with loading
Keyword then, the load mode have equally reached the loading capacity for reducing matched rule.
Preferably, above-mentioned three kinds of load modes can be used in combination in embodiments of the present invention, specifically, according to following
Load step is carried out:
First, rule database is searched whether to be stored with the first kind in judgment rule database, wherein, the
One type is identical with the type of web page resources corresponding to resource request, if the first kind can be found from rule database,
Then explanation is judged to be stored with the matched rule for belonging to the first kind in rule database, in this case, to regular data
The action scope of matched rule in storehouse under the first kind is obtained, and obtains the first action scope;
Then, judge whether include the first domain in the first action scope, wherein, the first domain is the website of initiation resource request
Domain, if judging, the first action scope includes the first domain, the pass of the matched rule to being applied to the first domain in rule database
Keyword is obtained, and obtains the first keyword;
Finally, judge whether the first character string includes the first keyword, wherein, the first character string is expression address information
Character string, if judging, the first character string includes the first keyword, to including the first keyword in rule database
Loaded with rule, i.e. extract complete rule all corresponding to the first keyword and loaded.Further, if should
Matched rule for the first domain have it is a plurality of if, then the keyword got can be multiple, i.e. the first keyword include it is multiple
Keyword, then judge whether include any keyword in multiple keywords in the first character string for such a situation, if judging
Going out the first character string includes any keyword in multiple keywords, it is determined that and the first character string includes the first keyword,
Assuming that keyword that the first character string includes is keyword K, then extracted from rule database corresponding to keyword K
All complete rules are loaded.
By use successively the type of web page resources corresponding to resource request, initiate the resource request website domain and
The address information of the website of resource request is initiated as index terms, the matched rule in rule database is screened successively,
Finally loading meets the matched rule of conditions above simultaneously, the loading capacity for further reducing matched rule is realized, with follow-up
When matched rule is matched with resource request, matched using lesser amount of matched rule, further improve matching
Efficiency.
It should be noted that in embodiments of the present invention, using description language as " first kind ", be intended merely to by
The type of web page resources corresponding to resource request makes a distinction with other types, is not that the order of the type of web page resources is done
Limit.Using as " the first action scope ", " the first keyword " the reasons why description language it is similar with described above.
By above description as can be seen that the matching process of the resource request of the embodiment of the present invention is broadly divided into two parts,
A part is that matched rule used in each function in browser is handled, and another part is to utilize the matching after processing
Rule carries out matching treatment to resource request, and this two parts flow is independently carried out in different phase, is independent of each other respectively, wherein,
Classification processing to matched rule is carried out before the matching treatment of resource request.The embodiment of the present invention to matched rule by entering
Specific classification of having gone is handled(Divided according to characteristics such as type, action scopes), matched to a certain resource request
When, the specific matched rule of loading section is only needed every time;According to the handling process of the embodiment of the present invention(Show in Fig. 4
Go out), no matter matched rule total quantity number, each resource request in the case of no repeated matching rule only need to carry out 2-
4 comparisons, you can complete complete matching process, reduce matching times;Traditional is single regularly by the resource of browser
The matching flow that request is compared one by one with character string rule, the comparison number required for each resource request are essentially identical to
The total quantity of rule;The two is compared, and the matching process of the embodiment of the present invention significantly improves matching efficiency.
Further, after matched rule is received, and in type, action scope and the key for obtaining matched rule
Before word, the matching process of the embodiment of the present invention also includes the judgement whether changed matched rule, illustrates herein
A kind of method for judging matched rule and whether changing:First, the time attribute of the matched rule to receiving obtains,
And the time attribute of rule database is obtained;Then, contrast judges that the time attribute of the matched rule received is corresponding
At the time of whether at the time of the time attribute of rule database corresponds to after, if the former after the latter, illustrates previous
The secondary classification storage that carried out to matched rule to after rule database, changed by matched rule, need in this case to
Classification storage is carried out again with rule;If the former not after the latter, illustrates once to carry out classification preceding to matched rule and deposit
After storing up rule database, matched rule is not changed, in this case without carrying out subseries again to matched rule
Storage.
Wherein, it is determined in the matching process of the embodiment of the present invention in the type to web page resources corresponding to resource request
It is that following methods can be used to carry out:First the core type for producing resource request is obtained and judges to produce resource request
Core type is Webkit kernels or Trident kernels.In the case of browser kernel is Webkit kernels, browser leads to
When crossing Webkit kernels generation resource request, modification can be made in encapsulated layer, it is passed through when asking resource
ResourceDispatcherHostImpl::OnRequestResource、 ResourceDispatcherHostImpl::
The functions such as BeginRequest, which are adjusted back, gives processing function, because Webkit kernels internally predefine ResourceType, institute
Can directly be acquired for resource type corresponding to resource request caused by Webkit kernel browsers;And for clear
Device kernel of looking at is the situation of Trident kernels, to web page resources corresponding to resource request caused by the browser kernel really
It is fixed, program registration " asynchronous to insert agreement " can be passed through(Asynchronous Pluggable Protocol), make the kernel please
All resources asked are via COInetProt::StartEx、CInternetProtocolFilter::The functions such as Start are adjusted back
To program, the address information of all resource requests is obtained with this, and by classifying to the extension name information of the address information
The type for the web page resources asked.
The embodiment of the present invention additionally provides a kind of coalignment of resource request, and the embodiment of the present invention is provided below
The matching of resource request is this to be specifically introduced:
Fig. 5 is the schematic diagram of coalignment according to embodiments of the present invention, as shown in figure 5, the coalignment of the embodiment
Including first acquisition unit 10, loading unit 20 and matching unit 30.
Specifically, first acquisition unit 10 is used for the feature for obtaining resource request, specifically, when user is beaten by browser
When opening webpage, browser can produce resource request first, obtain asking with resource by responding resource request again afterwards
Corresponding web page resources are sought, wherein, the feature for obtaining resource request is mainly to obtain domain, the money of the website for initiating resource request
The address information of the website of the type of web page resources and initiation resource request corresponding to the request of source.
Loading unit 20 is used for matched rule corresponding with the feature of resource request in loading rule database, wherein,
Rule database be browser in matched rule carry out classification storage database, i.e. in loading rule database with resource
The feature of request has the matched rule of corresponding relation.
Matching unit 30 is used to match resource request using the matched rule of loading.Specifically, can use existing
Have technology any one to resource request carry out matching treatment method.
The coalignment of the embodiment of the present invention to resource request when carrying out rule match, by being carried out to resource request
During rule match, rule corresponding with the feature of resource request in rule base is obtained, reduction is realized and resource request is carried out
The matching times of rule match, avoid and carry out resource request with strictly all rules in rule base to match caused processing successively
Efficiency is low, treatment effeciency is low when solving the problems, such as in the prior art to match resource request, and then improves money
Ask the effect of matching efficiency in source.
The matching process that matching unit 30 is matched using the matched rule of loading to resource request is:
First, the character of the character string for obtaining the address information for representing resource request respectively and the matched rule for representing loading
String, wherein, the character string for representing the address information of resource request is the word corresponding to the URL addresses of the website of initiation resource request
Symbol string, the character string for representing the matched rule of loading are the coded string of the matched rule loaded.Wherein, if loading unit 20
When the matched rule of middle loading includes a plurality of matched rule, then to representing that the character string of each bar matched rule obtains, obtain
To a plurality of character string, one matched rule of a string representation.
Then, judge to represent that the character string of the address information of resource request and the character string of the matched rule of expression loading are
It is no identical, i.e. judge whether the character string of matched rule of the URL address characters string of resource request with representing loading is identical, its
In, if if the matched rule loaded in loading unit 20 is more rules, the word of the address information of resource request will be represented
Symbol string is contrasted identical to judge whether with each character string got.
Finally, if judging to represent the character of matched rule of the character string of the address information of resource request with representing loading
Go here and there identical, it is determined that the matched rule of resource request and browser matches.If the matched rule bag loaded in loading unit 20
A plurality of matched rule is included, then is carried out in each character string that will be represented the character string of the address information of resource request and get
After contrast judges, if judging to represent the character string of the address information of resource request and any character string phase in a plurality of character string
Together, it is determined that the matched rule of resource request and browser matches.
In the embodiment of the present invention when carrying out classification storage to matched rule, the rule process in coalignment can be used
Unit is handled, wherein, figure 6 illustrates as shown in fig. 6, rule process unit includes the schematic diagram of rule process unit
Original regular reading unit, indexing units and fast table output unit, wherein, original regular reading unit(That is, receiving unit)With
It is read out in the matched rule in browser, indexing units are used to handle matched rule, and fast table output unit is
The unit stored to the output result of indexing units, that is to say rule database.Wherein, indexing units mainly pass through second
Acquiring unit and the first to the 3rd processing unit are handled matched rule:
Specifically, second acquisition unit is used for the type, action scope and keyword for obtaining matched rule, wherein, so-called class
The enumeration type of the predetermined coded string of program when type refers to encode matched rule, so-called action scope refer to matching rule
What then need to come into force under domain name, i.e. the domain name of the adaptable loading website of matched rule is the work of the matched rule
With domain, so-called loading website refers to the website loaded to web page resources, initiates resource request in embodiments of the present invention
Website is a loading website;First processing units are used to classify to matched rule according to the enumeration type got,
And store the type got and matched rule and the corresponding relation of type, i.e. correspondingly deposit each rule in matched rule
Under the enumeration type of Chu Qi ownership;Second processing unit is used to classify to matched rule according to getting action scope, and
Store the action scope got and matched rule and the corresponding relation of action scope, i.e. each rule in matched rule is corresponding
It is stored under the action scope that it is applied;3rd processing unit is used to divide matched rule according to the keyword got
Class, and store the corresponding relation of keyword and matched rule and keyword, i.e. by the corresponding storage of each rule in matched rule
Under corresponding keyword.Wherein, second acquisition unit is by reading subelement to representing that the character string of matched rule is read
Take, first character is often read in reading process, i.e., by segmentation subelement to representing that the character string of matched rule is carried out
Once split, obtain multiple separating character strings, wherein, so-called first character refers to the word in addition to alphabetic character and numerical character
Symbol;Then by statistics subelement count character in each separating character string number how much;Word is finally determined by determination subelement
Accord with the keyword that the largest number of separating character strings are matched rule.
In the embodiment of the present invention when being loaded to matched rule, the requesting processing in coalignment can be used
Handled, wherein, figure 7 illustrates as shown in fig. 7, requesting processing includes type to the schematic diagram of requesting processing
Matching unit, action scope matching unit and Keywords matching unit.
Wherein, type matching unit is also referred to as the first loading subelement, is mainly used in providing with webpage corresponding to resource request
The type in source as index terms, and according in types index mode loading rule database with resource request request web page resources
The corresponding matched rule of type, wherein, types index loads according to the type of matched rule to matched rule, i.e.
Loaded and the matching under the type identical type from rule database according to the type of web page resources corresponding to resource request
Rule, the matched rule for avoiding the type for loading web page resources corresponding with resource request from differing is reached, has reduced matching
The loading capacity of rule.
Action scope matching unit is also referred to as the second loading subelement, is mainly used in initiate the domain of the website of resource request work
For index terms, and it is corresponding according to the domain of the website in action scope indexed mode loading rule database with initiating resource request
Matched rule, wherein, effect Domain Index loads according to the action scope of matched rule to matched rule, i.e. is provided according to initiation
The domain of the website of source request loads the matched rule being applied under the domain from rule database, has reached and has avoided loading from not answering
The matched rule under the domain for the website for initiating resource request is used, reduces the loading capacity of matched rule.
Keywords matching unit is also referred to as the 3rd loading subelement, is mainly used in initiate the address of the website of resource request
Information as index terms, and according in keyword index mode loading rule database with initiate resource request website address
The corresponding matched rule of information, wherein, keyword index loads according to the keyword of matched rule to matched rule,
That is, loaded according to address information, the matched rule corresponding with initiating the address information of website of resource request meets:Table
Show the keyword of the matched rule in the character string of address information with loading, the load mode has equally reached reduction matching rule
Loading capacity then.
Further, the type matching unit in the embodiment of the present invention, action scope matching unit and Keywords matching unit
The loading for carrying out matched rule can be combined, specifically, be used to press by the first judge module in the first loading subelement
According to the type of web page resources corresponding to resource request(The hereinafter referred to as first kind)Search whether to be stored with from rule database
With the first kind, judge to be stored with the first kind in rule database if searching, then explanation is judged in rule database
The matched rule for belonging to the first kind is stored with, now, by the first acquisition module in the first loading subelement to regular number
Obtained according to the action scope of the matched rule under the first kind in storehouse, obtain the first action scope;Then it is single by the second loading
The second judge module in member searches judge whether include the first domain in the first action scope, wherein, the first domain please to initiate resource
The domain for the website asked, if judging, the first action scope includes the first domain, and mould is obtained by second in the second loading subelement
Block obtains to the keyword for being applied to the matched rule in the first domain in rule database, obtains the first keyword;Finally, by
The 3rd judge module in 3rd loading subelement judges whether the first character string includes the first keyword, wherein, the first character
Go here and there to represent the character string of address information, if judging, the first character string includes the first keyword, single by the 3rd loading
Load-on module in member loads to the matched rule for including the first keyword in rule database, i.e. extracts the first pass
All complete rules are loaded corresponding to keyword.
By using type matching unit, action scope matching unit and Keywords matching unit successively in rule database
Matched rule screened successively, finally loading meets the matched rule of conditions above simultaneously, realizes and further reduces
Loading capacity with rule, when subsequently being matched matched rule with resource request, to be entered using lesser amount of matched rule
Row matching, further improves matching efficiency.
As can be seen from the above description, the present invention realizes the matching times for being significantly reduced each resource request,
Lift matching speed;Simultaneously because original match rule process is separated and independently performed with resource matched processing procedure, and in resource
The matched rule loaded is needed to greatly reduce every time in matching process, therefore in the matching process, the resource occupation of program is also big
The reduction of amplitude.Using the method for the present invention, especially when browser handles ample resources matching request, can greatly improve
Program processing speed, reduce program CPU(Central Processing Unit, central processing unit)And memory source takes.
It should be noted that can be in such as one group of computer executable instructions the flow of accompanying drawing illustrates the step of
Performed in computer system, although also, show logical order in flow charts, in some cases, can be with not
The order being same as herein performs shown or described step.
Obviously, those skilled in the art should be understood that above-mentioned each module of the invention or each step can be with general
Computing device realize that they can be concentrated on single computing device, or be distributed in multiple computing devices and formed
Network on, alternatively, they can be realized with the program code that computing device can perform, it is thus possible to they are stored
Performed in the storage device by computing device, either they are fabricated to respectively each integrated circuit modules or by they
In multiple modules or step be fabricated to single integrated circuit module to realize.So, the present invention is not restricted to any specific
Hardware and software combines.
The preferred embodiments of the present invention are the foregoing is only, are not intended to limit the invention, for the skill of this area
For art personnel, the present invention can have various modifications and variations.Within the spirit and principles of the invention, that is made any repaiies
Change, equivalent substitution, improvement etc., should be included in the scope of the protection.