WO2015081789A1 - 网址净化方法及装置 - Google Patents
网址净化方法及装置 Download PDFInfo
- Publication number
- WO2015081789A1 WO2015081789A1 PCT/CN2014/091924 CN2014091924W WO2015081789A1 WO 2015081789 A1 WO2015081789 A1 WO 2015081789A1 CN 2014091924 W CN2014091924 W CN 2014091924W WO 2015081789 A1 WO2015081789 A1 WO 2015081789A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- url
- template
- regular expression
- command word
- matching
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/955—Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
- G06F16/9566—URL specific, e.g. using aliases, detecting broken or misspelled links
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/951—Indexing; Web crawling techniques
Definitions
- the invention relates to a method for purifying a website and a device thereof, in particular to a method for purifying a website in a website with a large number of web addresses.
- URL Uniform Resoure Locator
- ⁇ Intemet resource type indicates the tool that the WWW client program uses to operate. For example, "http://” means the WWW server, “ftp://” means the FTP server, “gopher://” means the Gopher server, and “new:” means the Newgroup newsgroup.
- Server address Indicates the server domain name where the WWW page is located.
- Path Indicates the location of a resource on the server (in the same format as the DOS system, usually with a directory/subdirectory/filename structure). Like ports, paths are not always needed.
- the URL address format is arranged as: scheme://host:port/path, for example http://www.microsoft.com:80/products is a typical URL address.
- a method of URL purification comprising the steps of:
- a computer program comprising computer readable code which, when run on a computer, performs the aforementioned method of URL purification.
- a computer readable medium storing the aforementioned computer program is provided.
- the present invention also provides a website cleaning apparatus, the apparatus comprising the following modules:
- the domain name matching module matches the original URL with the domain name in the purifiable domain name collection
- the positioning module locates the corresponding URL template set according to the successfully matched domain name
- a template matching module that matches the original URL with a regular expression of the URL template in the set of URL templates
- the command word processing module determines whether the template containing the regular expression matches the command word; if yes, the URL is processed according to the command word, and the output module outputs the cleaned new URL, otherwise the original URL is returned;
- the output module outputs the cleaned new URL.
- a URL purification method can be used to perform a pre-processing on a URL that needs to be crawled before the crawler crawls the webpage, and convert various forms of URLs into the same form, and in the present invention. Call it URL cleanup or URL normalization.
- URL cleanup or URL normalization For the URL after purification, In the form of Bloom filter, it is determined whether a web page has been crawled. If it has been crawled, it does not need to be crawled again. This can significantly improve the crawling ability of the crawler to capture effective web pages, saving Various resources (such as storage space, bandwidth, CPU, memory, etc.).
- FIG. 1 shows a flow chart of a URL purification process according to an embodiment of the present invention
- FIG. 2 is a schematic diagram showing a specific embodiment of a URL purification process according to FIG. 1;
- FIG. 3 is a schematic structural diagram of a URL template in a specific embodiment of the present invention.
- FIG. 4 is a schematic structural diagram of a web site purifying apparatus according to another embodiment of the present invention.
- Figure 5 schematically shows a block diagram of a server for performing the method according to the invention
- Fig. 6 schematically shows a storage unit for holding or carrying program code implementing the method according to the invention.
- a URL purification method includes the following steps:
- Step S110 Grab the original website and prepare to enter the purification process.
- Step S120 Perform exact domain name matching. Before the URL is processed by the template, the domain name must be matched exactly, and the original URL to be processed and the domain name in the purifiable domain name collection are matched one by one. If the match is successful, the process proceeds to step S130, otherwise the original URL is returned. One or more domain names are included in the domain name collection.
- Step S130 After the domain name is successfully matched, the successfully matched domain name is mapped to the corresponding URL template set, and the URL template set under the domain name is taken out.
- Step S140 Match all the URL templates in the URL template set in sequence with the original URL, and specifically match the original URL with the regular expression of the URL template in the URL template collection to determine whether the matching is matched. If the match is successful, the subsequent purification process will be performed, and step S150 is performed; otherwise, the original URL is returned.
- One or more URL templates are included in the URL template collection.
- step S150 it is determined whether the regular expression matches the successful template, and if the command word is included, if the command word is included, step S160 is performed; otherwise, the original website address is returned.
- step S160 the URL is processed according to the command word to determine whether the processing is successful. If the processing succeeds, the cleaned new website is output, otherwise, the original website is returned.
- Step S210 Grab the original website and enter the purification process.
- Step S220 Perform exact domain name matching to determine whether the matching is successful. If the matching is successful, proceed to step S230, otherwise perform step S270.
- Step S230 After the domain name is successfully matched, the successfully matched domain name is mapped to the corresponding URL template set, the URL template set under the domain name is taken out, and the original URL is matched with the regular expression of the URL template in the URL template set, and the judgment is performed. If the matching is successful, if the matching is successful, the subsequent purification processing is performed, and step S240 is performed; otherwise, step S270 is performed.
- step S240 after the URL template is successfully matched, it is determined whether the URL template matching the regular expression matches the command word goodsid. If there is a command word goodsid, step S241 is performed; if there is no command word goodsid, step S250 is performed.
- Step S241 determining whether the URL template containing the command word goodsid includes a URL custom standard form. If the URL custom standard form is included, the goodsid is extracted, and a new URL is generated according to the customized standard form, that is, after the output is purified. The new URL, the processing ends; otherwise, step S250 is performed.
- Step S250 determining whether the command word includes truncate, and if so, extracting the group matching parts in all the matching regular expressions, and combining the group matching parts into a new URL return, that is, outputting the purified new web address, and the processing ends; otherwise, Step S260 is performed.
- Step S260 determining whether the command word includes some grouping commands. If there are some grouping commands, the grouping string is processed and then re-spliced into a URL to return, that is, the cleaned new web address is output, and the processing ends; otherwise, step S270 is performed.
- step S270 the original URL (original URL data) is returned, and the processing is ended.
- Each URL template can be composed of three elements: a domain name, a regular expression, and a command word, or can be composed of four elements: a domain name, a regular number. Expressions, command words, and custom standard forms. URL templates are organized by domain name. Command words may contain a combination of one or more commands. When there are multiple command words, they are separated by ".” (such as up_1.goodsid_1).
- Embodiment 1 The command word goodsid, the command word is applicable to the overall URL form is relatively variable, it is necessary to summarize the law, find out the main part, and then splicing out the final form of the website.
- the command word goodsid is used to customize the extraction of the trunk.
- the rules for the return form need to be customized:
- Embodiment 2 The command word truncate, this command word is applicable to the case where the URL is followed by additional information.
- this form is more common and easier to handle, for example:
- the method of purifying such a URL is to use the command word truncate to set the grouping (adding a pair of parentheses) to all the data that needs to be retained, and only return the result of the grouping, such as the following rule. :
- Embodiment 3 The command word is a grouping command, and the command word is applicable to a website whose URL is not case sensitive. Some websites are insensitive to the case of URLs, but for crawlers, URL uppercase and lowercase correspond to different links. In this case, you can use grouping commands to uniformly capitalize a group. Convert to lowercase or lowercase to uppercase.
- the command word up or low can be used to control the case of the matching packet, up_n represents the nth group converted to uppercase, and low_n represents the nth group converted to lowercase. As follows:
- the cleaned website can improve the ability of the search engine crawler to capture the effective webpage and the actual use efficiency of the crawler, thereby saving various resources.
- a website purification device 400 includes the following modules:
- the domain name matching module 410 matches the original website address with the domain name in the purifiable domain name set, and the domain name set includes one or more domain names.
- the location module 420 is configured to locate a corresponding set of URL templates according to the successfully matched domain name, and the URL template set includes one or more URL templates.
- the template matching module 430 matches the original URL with a regular expression of the URL template in the URL template collection, and the URL template includes a domain name, a regular expression, a command word, and a custom form (optional).
- the command word processing module 440 determines whether the template containing the regular expression matches the command word; if yes, the URL is processed according to the command word, and the output module outputs the cleaned new URL, otherwise the original URL is returned. Specifically, when the command word processing module 440 determines that the command word included in the template that the regular expression matches successfully is goodsid, and the template with the regular expression matching successfully includes a custom form, the URL is processed according to the command word.
- the method includes: extracting the goodsid, generating a new web address according to the custom form standard; and when the command word processing module 440 determines that the command word included in the template matching the regular expression is successful is truncate, extracting the grouping in the regular expression matching the success
- the matching part combines the parts into a new web address; when the command word processing module 440 determines that the command word included in the template matching the regular expression is a grouping command, the grouping string is processed and re-spliced into a new web address.
- the grouping command includes a low_n command indicating that the nth group is converted to a lowercase form, an up_n command indicating that the nth group is converted to an uppercase form, and a command word processing module 440 determining a command word included in a template in which the regular expression matches successfully.
- the output module 450 outputs the purified new web address.
- the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
- a microprocessor or digital signal processor DSP
- the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
- a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals.
- signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
- Figure 5 illustrates a server, such as a search engine server, that can implement the above method in accordance with the present invention.
- the server conventionally includes a processor 510 and a computer program product or computer readable medium in the form of a memory 530.
- the memory 530 may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read Only Memory), an EPROM, a hard disk, or a ROM.
- Memory 530 has a memory space 550 for program code 551 for performing any of the method steps described above.
- storage space 550 for program code may include various program code 551 for implementing various steps in the above methods, respectively.
- the program code can be read from or written to one or more computer program products.
- These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
- Such computer program products are typically portable or fixed storage units as described with reference to FIG.
- the storage unit may have a storage section, a storage space, and the like arranged similarly to the storage 530 in the server of FIG.
- the program code can be compressed, for example, in an appropriate form.
- the storage unit includes computer readable code 551', code that can be read by a processor, such as 510, which, when executed by a server, causes the server to perform various steps in the methods described above.
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Information Transfer Between Computers (AREA)
Abstract
本发明提供了一种网址净化方法,包括以下步骤:将原始网址与可净化的域名集合中的域名进行匹配;根据匹配成功的域名定位到对应的网址模板集合;将原始网址与该网址模板集合中的网址模板的正则表达式进行匹配;判断正则表达式匹配成功的模板中是否包含命令字;若是则根据命令字对网址进行处理,转到输出净化后的新网址步骤,否则返回原始网址;输出净化后的新网址。此外本发明还相应地提供一种的网址净化装置。对于具备多种形式的网址,净化后可以判定其是否已经被抓取过,如果已经抓取就不必重复抓取,从而显著的提升爬虫抓取有效网页的能力,节省各种资源。
Description
本发明涉及一种网址净化方法及其装置,尤其涉及一种对网址形式较多的网站中的网址进行净化的方法。
URL(Uniform Resoure Locator:统一资源定位器)是网络资源的地址,也称为网址。在本发明中,以中文的“网址”和英文缩写“URL”表示同一个概念。它从左到右由下述部分组成:
·Intemet资源类型(scheme):指出WWW客户程序用来操作的工具。如“http://”表示WWW服务器,“ftp://”表示FTP服务器,“gopher://”表示Gopher服务器,而“new:”表示Newgroup新闻组。
·服务器地址(host):指出WWW页所在的服务器域名。
·端口(port):有时(并非总是需要),对某些资源的访问来说,需给出相应的服务器提供端口号。
·路径(path):指明服务器上某资源的位置(其格式与DOS系统中的格式一样,通常有目录/子目录/文件名这样结构组成)。与端口一样,路径并非总是需要的。
URL地址格式排列为:scheme://host:port/path,例如http://www.microsoft.com:80/products就是一个典型的URL地址。
现如今天随着网站推广手段的日愈丰富,广大网站为了统计当前URL的流量来源,会对URL做一些额外的处理,有的会在URL主体后面加上一些额外的信息,有的则是变化了URL的形式,这些额外的形式提高了网站的效率,但是对于搜索引擎的爬虫来说,却是噩梦,因为现有技术的爬虫在抓取的时候,并不会主动区分这些额外的信息,而会分别对这些变化的URL进行抓取,但是抓取的内容却是指向同一个网页。对于爬虫来说,则浪费了URL调度模块
的存储空间,带宽,以及计算的资源,导致爬虫的实际使用效率不高。
发明内容
鉴于上述问题,需要提升搜索引擎的爬虫抓取有效网页的能力及爬虫的实际使用效率,从而节省各种资源等(例如存储空间、带宽、CPU、内存等)。
因此,依据本发明的一个方面,提供了一种网址净化方法,该方法包括以下步骤:
将原始网址与可净化的域名集合中的域名进行匹配;
根据匹配成功的域名定位到对应的网址模板集合;
将原始网址与该网址模板集合中的网址模板的正则表达式进行匹配;
判断正则表达式匹配成功的模板中是否包含命令字;若是则根据命令字对网址进行处理,转到输出净化后的新网址步骤,否则返回原始网址;
输出净化后的新网址。
依据本发明的另一个方面,提供了一种计算机程序,包括计算机可读代码,当所述计算机可读代码在计算机上运行时,将执行前述的网址净化方法。
依据本发明的又一个方面,提供了一种计算机可读介质,其中存储了前述的计算机程序。
根据本发明的再一方面,本发明还提出了一种网址净化装置,该装置包括以下模块:
域名匹配模块,将原始网址与可净化的域名集合中的域名进行匹配;
定位模块,根据匹配成功的域名定位到对应的网址模板集合;
模板匹配模块,将原始网址与该网址模板集合中的网址模板的正则表达式进行匹配;
命令字处理模块,判断正则表达式匹配成功的模板中是否包含命令字;若是则根据命令字对网址进行处理,转到输出模块输出净化后的新网址,否则返回原始网址;
输出模块,输出净化后的新网址。
根据本发明实施例的一种网址净化方法可以看出,在爬虫抓取网页之前,对于需要抓取的URL进行一遍预处理,将多种形式的URL转化为同一种形式,在本发明中也称之为URL净化或者URL归一化。对于净化以后的URL,可
以采取Bloom filter(布隆过滤器)的形式判定一个网页是否已经被抓取过,如果已经抓取,就不需要再抓取一遍,这样,可以显著的提升爬虫抓取有效网页的能力,节省各种资源(例如存储空间、带宽、CPU、内存等)。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1示出了根据本发明一个实施例的网址净化处理流程图;
图2示出了根据图1网址净化处理流程的具体实施例示意图;
图3示出了本发明一个具体实施例中的URL模板结构示意图;
图4示出了根据本发明另一个实施例的网址净化装置的结构示意图;
图5示意性地示出了用于执行根据本发明的方法的服务器的框图;以及
图6示意性地示出了用于保持或者携带实现根据本发明的方法的程序代码的存储单元。
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。
如图1所示,一种网址净化方法,包括以下步骤:
步骤S110:抓取原始网址,准备进入净化处理过程。
步骤S120:进行域名精准匹配。在URL进行模板处理前,都要先进行域名精确匹配,将待处理的原始网址与可净化的域名集合中的域名逐一进行匹
配,判断匹配是否成功,若匹配成功则进行步骤S130,否则返回原始网址。域名集合中包括一个或多个域名。
步骤S130,域名匹配成功后,将匹配成功的域名定位到对应的网址模板集合,取出所属域名下的网址模板集合。
步骤S140,将网址模板集合中的所有网址模板按照顺序,依次与原始网址进行URL模板匹配,具体的,是将原始网址与该网址模板集合中的网址模板的正则表达式进行匹配,判断匹配是否成功,如果匹配成功才会进行后续净化处理,执行步骤S150,否则返回原始网址。网址模板集合中包括一个或多个网址模板。
步骤S150,判断正则表达式比配成功的模板中是否包含命令字,如果包含命令字,则执行步骤S160,否则,返回原始网址。
步骤S160,根据命令字对网址进行处理,判断是否处理成功,若处理成功则输出净化后的新网址,否则,返回原始网址。
下面结合附图2,依据上述处理流程,以具体实施例的方式详细说明网址净化过程,特别是依据命令字对网址进行的净化处理:
步骤S210:抓取原始网址,进入净化处理过程。
步骤S220:进行域名精准匹配,判断匹配是否成功,若匹配成功则进行步骤S230,否则执行步骤S270。
步骤S230,域名匹配成功后,将匹配成功的域名定位到对应的网址模板集合,取出所属域名下的网址模板集合,将原始网址与该网址模板集合中的网址模板的正则表达式进行匹配,判断匹配是否成功,如果匹配成功才会进行后续净化处理,执行步骤S240,否则执行步骤S270。
步骤S240,网址模板匹配成功后,判断该正则表达式匹配成功的网址模板中是否包含有命令字goodsid,若有命令字goodsid,则执行步骤S241;若没有命令字goodsid,则执行步骤S250。
步骤S241,判断含有命令字goodsid的网址模板中是否包含有URL自定义标准形式,若含有URL自定义标准形式,则抽取出goodsid,根据自定义标准形式,生成新的URL返回,即输出净化后的新网址,处理结束;否则,执行步骤S250。
步骤S250,判断命令字是否包括有truncate,若是则抽取所有匹配成功的正则表达式中分组匹配部分,将这些分组匹配部分组合成新的URL返回,即输出净化后的新网址,处理结束;否则执行步骤S260。
步骤S260,判断命令字是否包括有某些分组命令。若有某些分组命令,则将分组字符串处理后重新拼成URL返回,即输出净化后的新网址,处理结束;否则执行步骤S270。
步骤S270,返回原始网址(原始URL数据),结束处理过程。
根据上述处理过程,URL模板的机构如图3所示,每个URL模板(网址模板)可以由三个元素组成:域名、正则表达式和命令字,也可以由四个元素组成:域名、正则表达式、命令字和自定义标准形式。URL模板是按域名划分组织的,命令字可能包含一个或多个命令的组合,当有多个命令字时由“.”分隔开(如up_1.goodsid_1)。
本发明在网址净化处理过程中支持并使用到的命令字,其名称及相应解释如下表所示:
| 名称 | 解释 |
| goodsid_n | 从第n个组内提取goodsid信息 |
| truncate | 只保留组匹配的信息,返回截并的结果 |
| Low_n | 第n组转换成小写形式 |
| up_n | 第n组转换成大写形式 |
对于本发明中命令字的使用方法,下面具体举例说明:
实施例一:命令字goodsid,这种命令字适用于整体URL形式比较多变,需要总结出规律,找出其中的主要部分,然后拼接出来最终形式的网站。
例如,某些B2C网站链接形式不太规范,同一时间网站上会出现多种形式的链接,如下:
http://www.eggcoo.com/page_product_527393_0.html
http://www.eggcoo.com/product.shtml?method=detailView&id=527393&cv=0
这是在金蛋商场里,存在两种不同形式的链接,但事实上指向的却是同一个商品。
又例如,有些历史悠久的大B2C,也会不定期地改版,存在同样状况:
http://www.amazon.cn/gp/product/B0019DBU60?ver=gp&uid=476-6816060-6082564&pageletid=taiwan(来自列表页)
http://www.amazon.cn/mn/detailApp/ref=sr_1_1?_encoding=UTF8&s=electro nics&qid=1278389145&asin=B0019DBU60&sr=8-1(来自搜索页)
http://www.amazon.cn/%CC%C0%C4%B7%D1%B7+%C0%F2%C2%EA+%B1%CA%BC%C7%B1%BE%D2%F4%CF%E4+DS-A07203%2C%CC%F4%D5%BD%D0%D4%BC%DB%B1%C8%BC%AB%CF%DE%21/dp/B0019DBU60(来自sitemap)
这是在卓越亚马逊的链接,存在三种不同形式的链接,但事实上指向的却是同一个商品。
对于上述这类网址的净化办法,就是采用命令字goodsid,自定义抽取主干,这时,就需要自定义返回形式的规则了:
(1)针对金蛋商场,需要编写如下规则:
{“www.eggcoo.com”,“^/product.shtml\?.*id=(\d+).*$”,“goodsid_1”,“/product.shtml\?.*id=%s”}
{“www.eggcoo.com”,“^/page_product_(\d+)_(\d+).html”,“goodsid_1”,“/product.shtml\?.*id=%s”}
应用这两条规则,上述金蛋商场的链接会返回
http://www.eggcoo.com/page_product_527393_0.html
(2)针对卓越亚马逊,需要编写如下规则:
{“www.amazon.cn”,“^/gp/product/([A-Za-z0-9]+)\?ver=gp.*$”,“up_1.goodsid_1”,“/gp/product/%s”}
{“www.amazon.cn”,“^/mn/detailApp/ref-.*\?.*asin=([A-Za-z0-9]+).*$”,“up_1.goodsid_1”,“/gp/product/%s”}
{“www.amazon.cn”,“^/(.*)/dp/([A-Za-z0-9]+).*$”,“up_2.goodsid_2”,“/gp/product/%s”}
应用这三条规则,上述卓越亚马逊的链接会返回
http://www.amazon.cn/gp/product/B0019DBU60
实施例二:命令字truncate,这种命令字适用于URL后面跟有额外的信息的情况。现在很多网站都会在URL后面加上额外的一些参数,标记来源,或者做统计,这种形式比较常见,处理起来也比较容易,例如:
http://www.vancl.com/Product_0006984/BaiHeHuaLianYiQun%20HongSeYi nHua.html?Source=eqf&SourceSunInfo=96845|yqftid_12783880711284196186
对这类网址的净化办法,就是采用命令字truncate(截并),对所有需要保留下来的数据,都设置了分组(加了一对括号),只返回有分组的结果,如下面这条规则:
{“www.vancl.com”,“^(/Product_[0-9]+/[\w]+\.html).*.*$”,“truncate”,null}
应用这个规则,遇到上述的链接时返回
http://www.vancl.com/Product_0006984/BaiHeHuaLianYiQun%20HongSeYi nHua.html
实施例三:命令字为分组命令,这种命令字适用于URL不区分大小写的网站。有些网站,对于URL的大小写是不敏感的,但是对于爬虫来说,URL大写和小写却分别对应着不同的链接,碰到这种情况,就可以采用分组命令统一的将某个分组的大写转化成小写或者小写转化成大写。
例如当当网的URL:
http://product.dangdang.com/product.aspx?product_id=22799821
http://product.dangdang.com/Product.aspx?product_id=22799821
这两个URL虽然不同,但指向的是同一件商品。
对这类网址的净化,可以采用命令字up或low对匹配分组部分进行大小写控制,up_n代表第n组转换成大写形式,low_n代表第n组转换成小写形式。如下面这条规则:
{“product.dangdang.com”,“(?i)^/(P)roduct.aspx?product_id=\d+.*$”,“low_1”,null}
这条规则表示将第一个匹配组小写返回。同理,将“low_1”换成“up_1”则表示将第一个匹配组大写返回。
通过本发明的实施例可以看出,净化后的网址,能够提升搜索引擎的爬虫抓取有效网页的能力及爬虫的实际使用效率,从而节省各种资源。
如图4所示,是本发明的另一个实施例,由于其原理与图1及上述表述的内容完全一致,因此在此并不展开详细说明。一种网址净化装置400,包括以下模块:
域名匹配模块410,将原始网址与可净化的域名集合中的域名进行匹配,域名集合中包括一个或多个域名。
定位模块420,根据匹配成功的域名定位到对应的网址模板集合,网址模板集合中包括一个或多个网址模板。
模板匹配模块430,将原始网址与该网址模板集合中的网址模板的正则表达式进行匹配,网址模板包括域名、正则表达式、命令字、自定义形式(可选)。
命令字处理模块440,判断正则表达式匹配成功的模板中是否包含命令字;若是则根据命令字对网址进行处理,转到输出模块输出净化后的新网址,否则返回原始网址。具体的,当命令字处理模块440判断正则表达式匹配成功的模板中包含的命令字为goodsid,且所述正则表达式匹配成功的模板中包含自定义形式时,则根据命令字对网址进行处理,包括抽取出goodsid,根据自定义形式标准,生成新的网址;当命令字处理模块440判断正则表达式匹配成功的模板中包含的命令字为truncate时,则抽取匹配成功的正则表达式中分组匹配部分,将这些部分组合成新的网址;当命令字处理模块440判断正则表达式匹配成功的模板中包含的命令字为分组命令时,则将分组字符串处理后重新拼成新的网址,分组命令包括low_n命令和up_n命令,low_n命令表示第n组转换成小写形式,up_n命令表示第n组转换成大写形式;当命令字处理模块440判断正则表达式匹配成功的模板中包含的命令字为goodsid,但正则表达式匹配成功的模板中不包含自定义形式时,则进一步判断该正则表达式匹配成功的模板中是否包含命令字truncate,若是,则抽取匹配成功的正则表达式中分组匹配部分,将这些部分组合成新的网址;否则进一步判断该正则表达式匹配成功的模板中是否包含命令字分组命令,若是,则将分组字符串处理后重新拼成新的网址;否则返回原始网址。
输出模块450,输出净化后的新网址。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,
可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的客户端或服务器中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者设备程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
例如,图5示出了可以实现根据本发明上述方法的服务器,例如搜索引擎服务器。该服务器传统上包括处理器510和以存储器530形式的计算机程序产品或者计算机可读介质。存储器530可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器530具有用于执行上述方法中的任何方法步骤的程序代码551的存储空间550。例如,用于程序代码的存储空间550可以包括分别用于实现上面的方法中的各种步骤的各个程序代码551。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图6所述的便携式或者固定存储单元。该存储单元可以具有与图5的服务器中的存储器530类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括计算机可读代码551’,即可以由例如诸如510之类的处理器读取的代码,这些代码当由服务器运行时,导致该服务器执行上面所描述的方法中的各个步骤。
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下被实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并
且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
此外,还应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。
Claims (20)
- 一种网址净化方法,其特征在于包括以下步骤:将原始网址与可净化的域名集合中的域名进行匹配;根据匹配成功的域名定位到对应的网址模板集合;将所述原始网址与该网址模板集合中的网址模板的正则表达式进行匹配;判断正则表达式匹配成功的模板中是否包含命令字;若是,则根据命令字对网址进行处理,否则返回原始网址;输出净化后的新网址。
- 根据权利要求1所述的网址净化方法,其特征在于:当判断正则表达式匹配成功的模板中包含的命令字为goodsid,且所述正则表达式匹配成功的模板中包含自定义形式时,则根据命令字对网址进行处理,包括抽取出goodsid,根据自定义形式标准,生成新的网址。
- 根据权利要求1所述的网址净化方法,其特征在于:当判断正则表达式匹配成功的模板中包含的命令字为truncate时,则抽取匹配成功的正则表达式中分组匹配部分,将这些部分组合成新的网址。
- 根据权利要求1所述的网址净化方法,其特征在于:当判断正则表达式匹配成功的模板中包含的命令字为分组命令时,则将分组字符串处理后重新拼成新的网址。
- 根据权利要求4所述的网址净化方法,其特征在于:当所述分组命令包括low_n命令,则表示第n组转换成小写形式;当所述分组命令包括up_n命令,则表示第n组转换成大写形式。
- 根据权利要求1所述的网址净化方法,其特征在于:当判断正则表达式匹配成功的模板中包含的命令字为goodsid,但所述正则表达式匹配成功的模板中不包含自定义形式时,则进一步判断该正则表达式匹配成功的模板中是否包含命令字truncate,若是,则抽取匹配成功的正则表达式中分组匹配部分,将这些部分组合成新的网址;否则进一步判断该正则表达式匹配成功的模板中是否包含命令字分组命令,若是,则将分组字符串处理后重新拼成新的网址;否则返回原始网址。
- 根据权利要求1-6之一所述的网址净化方法,其特征在于:所述域名集合中包括一个或多个域名,所述网址模板集合中包括一个或多个网址模板。
- 根据权利要求1-7之一所述的网址净化方法,其特征在于:所述网址模板包括域名、正则表达式和命令字。
- 根据权利要求8所述的网址净化方法,其特征在于:所述网址模板还包括自定义形式。
- 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在计算机上运行时,将执行根据权利要求1至9中的任一项所述的网址净化方法。
- 一种计算机可读介质,其中存储了如权利要求10所述的计算机程序。
- 一种网址净化装置,其特征在于包括以下模块:域名匹配模块,将原始网址与可净化的域名集合中的域名进行匹配;定位模块,根据匹配成功的域名定位到对应的网址模板集合;模板匹配模块,将原始网址与该网址模板集合中的网址模板的正则表达式进行匹配;命令字处理模块,判断正则表达式匹配成功的模板中是否包含命令字;若是则根据命令字对网址进行处理,否则返回原始网址;输出模块,输出净化后的新网址。
- 根据权利要求12所述的网址净化装置,其特征在于:当所述命令字处理模块判断正则表达式匹配成功的模板中包含的命令字为goodsid,且所述正则表达式匹配成功的模板中包含自定义形式时,则根据命令字对网址进行处理,包括抽取出goodsid,根据自定义形式标准,生成新的网址。
- 根据权利要求12所述的网址净化装置,其特征在于:当所述命令字处理模块判断正则表达式匹配成功的模板中包含的命令字为truncate时,则抽取匹配成功的正则表达式中分组匹配部分,将这些部分组合成新的网址。
- 根据权利要求12所述的网址净化装置,其特征在于:当所述命令字处理模块判断正则表达式匹配成功的模板中包含的命令字 为分组命令时,则将分组字符串处理后重新拼成新的网址。
- 根据权利要求15所述的网址净化装置,其特征在于:当所述分组命令包括low_n命令,则表示第n组转换成小写形式;当所述分组命令包括up_n命令,则表示第n组转换成大写形式。
- 根据权利要求12所述的网址净化装置,其特征在于:当所述命令字处理模块判断正则表达式匹配成功的模板中包含的命令字为goodsid,但所述正则表达式匹配成功的模板中不包含自定义形式时,则进一步判断该正则表达式匹配成功的模板中是否包含命令字tru ncate,若是,则抽取匹配成功的正则表达式中分组匹配部分,将这些部分组合成新的网址;否则进一步判断该正则表达式匹配成功的模板中是否包含命令字分组命令,若是,则将分组字符串处理后重新拼成新的网址;否则返回原始网址。
- 根据权利要求12-17之一所述的网址净化装置,其特征在于:所述域名集合中包括一个或多个域名,所述网址模板集合中包括一个或多个网址模板。
- 根据权利要求12-17之一所述的网址净化装置,其特征在于:所述网址模板包括域名、正则表达式和命令字。
- 根据权利要求19所述的网址净化装置,其特征在于:所述网址模板还包括自定义形式。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US15/100,951 US20160306893A1 (en) | 2013-12-02 | 2014-11-21 | Url purification method and url purification apparatus |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201310632492.1A CN103793462B (zh) | 2013-12-02 | 2013-12-02 | 网址净化方法及装置 |
| CN201310632492.1 | 2013-12-02 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2015081789A1 true WO2015081789A1 (zh) | 2015-06-11 |
Family
ID=50669128
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2014/091924 Ceased WO2015081789A1 (zh) | 2013-12-02 | 2014-11-21 | 网址净化方法及装置 |
Country Status (3)
| Country | Link |
|---|---|
| US (1) | US20160306893A1 (zh) |
| CN (1) | CN103793462B (zh) |
| WO (1) | WO2015081789A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108228623A (zh) * | 2016-12-14 | 2018-06-29 | 北京国双科技有限公司 | 一种数据处理方法和客户端设备 |
Families Citing this family (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103793462B (zh) * | 2013-12-02 | 2016-08-31 | 北京奇虎科技有限公司 | 网址净化方法及装置 |
| CN105302815B (zh) * | 2014-06-23 | 2019-06-07 | 腾讯科技(深圳)有限公司 | 网页的统一资源定位符url的过滤方法和装置 |
| US9720814B2 (en) * | 2015-05-22 | 2017-08-01 | Microsoft Technology Licensing, Llc | Template identification for control of testing |
| CN104881496B (zh) * | 2015-06-15 | 2018-12-14 | 北京金山安全软件有限公司 | 一种文件名称识别及文件清理方法及装置 |
| CN104881495B (zh) * | 2015-06-15 | 2019-03-26 | 北京金山安全软件有限公司 | 一种文件夹路径识别及文件夹清理方法及装置 |
| CN105302876A (zh) * | 2015-09-28 | 2016-02-03 | 孙燕群 | 基于正则表达式的url过滤方法 |
| CN106682677A (zh) * | 2015-11-11 | 2017-05-17 | 广州市动景计算机科技有限公司 | 广告识别规则归纳方法、装置及设备 |
| CN112084438A (zh) * | 2020-09-01 | 2020-12-15 | 支付宝(杭州)信息技术有限公司 | 扫码跳转数据处理方法、装置、设备及系统 |
| CN114443990B (zh) * | 2022-02-08 | 2026-03-17 | 北京百度网讯科技有限公司 | 一种url归一化的方法及装置 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| TW201044212A (en) * | 2009-06-12 | 2010-12-16 | Alibaba Group Holding Ltd | Method and system for recognizing doubtful fake website |
| CN101977251A (zh) * | 2010-11-19 | 2011-02-16 | 苏州言诺信息科技有限公司 | 服务器端网址资源优化装置及其优化方法 |
| US8250080B1 (en) * | 2008-01-11 | 2012-08-21 | Google Inc. | Filtering in search engines |
| CN102882987A (zh) * | 2011-07-12 | 2013-01-16 | 阿里巴巴集团控股有限公司 | 域名过滤名单存储、匹配方法及装置 |
| CN102663058B (zh) * | 2012-03-30 | 2013-12-18 | 华中科技大学 | 一种分布式网络爬虫系统中的url去重方法 |
| CN103793462A (zh) * | 2013-12-02 | 2014-05-14 | 北京奇虎科技有限公司 | 网址净化方法及装置 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7599931B2 (en) * | 2006-03-03 | 2009-10-06 | Microsoft Corporation | Web forum crawler |
| CN101308495B (zh) * | 2007-10-24 | 2011-05-25 | 河北全通通信有限公司 | 局数据核查制作方法 |
| CN101604328A (zh) * | 2009-07-06 | 2009-12-16 | 深圳市汇海科技开发有限公司 | 一种互联网信息垂直搜索方法 |
| CN102867053A (zh) * | 2012-09-12 | 2013-01-09 | 北京奇虎科技有限公司 | 收集网站信息中有效信息网页的方法、装置及系统 |
-
2013
- 2013-12-02 CN CN201310632492.1A patent/CN103793462B/zh active Active
-
2014
- 2014-11-21 US US15/100,951 patent/US20160306893A1/en not_active Abandoned
- 2014-11-21 WO PCT/CN2014/091924 patent/WO2015081789A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8250080B1 (en) * | 2008-01-11 | 2012-08-21 | Google Inc. | Filtering in search engines |
| TW201044212A (en) * | 2009-06-12 | 2010-12-16 | Alibaba Group Holding Ltd | Method and system for recognizing doubtful fake website |
| CN101977251A (zh) * | 2010-11-19 | 2011-02-16 | 苏州言诺信息科技有限公司 | 服务器端网址资源优化装置及其优化方法 |
| CN102882987A (zh) * | 2011-07-12 | 2013-01-16 | 阿里巴巴集团控股有限公司 | 域名过滤名单存储、匹配方法及装置 |
| CN102663058B (zh) * | 2012-03-30 | 2013-12-18 | 华中科技大学 | 一种分布式网络爬虫系统中的url去重方法 |
| CN103793462A (zh) * | 2013-12-02 | 2014-05-14 | 北京奇虎科技有限公司 | 网址净化方法及装置 |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108228623A (zh) * | 2016-12-14 | 2018-06-29 | 北京国双科技有限公司 | 一种数据处理方法和客户端设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN103793462B (zh) | 2016-08-31 |
| US20160306893A1 (en) | 2016-10-20 |
| CN103793462A (zh) | 2014-05-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN103793462B (zh) | 网址净化方法及装置 | |
| CN104933056B (zh) | 统一资源定位符去重方法及装置 | |
| JP6203374B2 (ja) | ウェブページ・スタイルアドレスの統合 | |
| CN102411617B (zh) | 一种对海量url进行存储和查询方法 | |
| WO2014101783A1 (en) | Method and server for performing cloud detection for malicious information | |
| CN112115266B (zh) | 恶意网址的分类方法、装置、计算机设备和可读存储介质 | |
| CN103559313B (zh) | 搜索方法及装置 | |
| WO2015021879A1 (zh) | 一种数据正则表达式的挖掘方法及装置 | |
| CN105205080A (zh) | 冗余文件清理方法、装置和系统 | |
| CN102523130A (zh) | 不良网页检测方法及装置 | |
| CN105302876A (zh) | 基于正则表达式的url过滤方法 | |
| CN103399872A (zh) | 对网页抓取进行优化的方法和装置 | |
| US20120166412A1 (en) | Super-clustering for efficient information extraction | |
| CN106385407B (zh) | 一种应用识别待分析数据包去噪声的方法和装置 | |
| CN107577943B (zh) | 基于机器学习的样本预测方法、装置及服务器 | |
| CN105426500B (zh) | 网页脚本动态生成的链接的提取方法及装置 | |
| JP2018206189A (ja) | 情報収集装置、および、情報収集方法 | |
| CN103425646A (zh) | 一种web服务发现方法及其装置 | |
| CN110795915B (zh) | xml文件批量修改方法、系统、设备和计算机可读存储介质 | |
| CN115759067A (zh) | 敏感词的识别方法和敏感词树的构建方法 | |
| CN104778232A (zh) | 一种基于长查询的搜索结果的优化方法和装置 | |
| CN113221035A (zh) | 用于确定异常网页的方法、装置、设备、介质和程序产品 | |
| CN110543622A (zh) | 文本相似度检测方法、装置、电子设备及可读存储介质 | |
| WO2017113324A1 (zh) | 基于正则表达式的url过滤方法 | |
| CN106487771B (zh) | 网络行为的获取方法及装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 14867207 Country of ref document: EP Kind code of ref document: A1 |
|
| WWE | Wipo information: entry into national phase |
Ref document number: 15100951 Country of ref document: US |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 14867207 Country of ref document: EP Kind code of ref document: A1 |