Javier P. L. wrote:
Hi,
I am using Nutch for news sites crawling, I have a problem with one of
them that publishes the urls with & instead of &. I discovered the
use of the url normalizer and the regex-normalize.xml configuration
file. Unfortunately I did not find too much examples about how to use
the regular expressions and substitutions, so I was trying different
combinations to make the transformation but it did work.
Basically what I want is to convert
noticia.jsp?CAT=126&TEXTO=100000109668
in
noticia.jsp?CAT=126&TEXTO=100000109668
because otherwise Nutch is not capable to crawl those pages.
I am using Nutch 0.8.1 and I tried several different substitution
expressions, but finally I chose the next entry in regex-normalize.xml
but it did not work, so I assume that something is wrong
<regex>
<pattern>(.*)\&amp;TEXTO(.*)</pattern>
The backslash seems wrong - you should never put a literal ampersand in
an XML file, and backslash is no escape in XML, only named entities or
Unicode entities are. What you want here is this:
<pattern>(.*?)&amp;TEXTO(.*)</pattern>
Additional question mark makes the first pattern "reluctant", otherwise
it would match the whole string.
<substitution>$1&TEXTO$2</substitution>
Looks good to me.
--
Best regards,
Andrzej Bialecki <><
___. ___ ___ ___ _ _ __________________________________
[__ || __|__/|__||\/| Information Retrieval, Semantic Web
___|||__|| \| || | Embedded Unix, System Integration
http://www.sigram.com Contact: info at sigram dot com