Re: [Htmlparser-user] Reg extracting links corresponding to a search string
Brought to you by:
derrickoswald
|
From: Third E. <nav...@gm...> - 2006-02-15 16:31:33
|
Here is a sample for testing it out. This sample is in C#/.Net but you
should be able to adapt it to java code quickly.
static void TestLinkRegExFilterForPage(String strUrl)
=09=09{
=09=09=09Parser obParser =3D new Parser(new System.Uri(strUrl));
=09=09=09String strPatterns =3D "services*";
=09=09=09NodeFilter obLinkRegExFilter =3D new LinkRegexFilter(strPatterns);
=09=09=09NodeList nodes =3D obParser.ExtractAllNodesThatMatch(obLinkRegExFi=
lter);
=09=09=09if (nodes !=3D null)
=09=09=09{
=09=09=09=09for(Int32 i =3D 0; i < nodes.Count; i++)
=09=09=09=09{
=09=09=09=09=09INode obNode =3D nodes[i];
=09=09=09=09=09Console.WriteLine(obNode.GetText());
=09=09=09=09}
=09=09=09}
=09=09}
On 2/15/06, Lu=EDs Manuel dos Santos Gomes <lui...@dq...> wrot=
e:
> Hi Raj
>
> Check out the example applications bundled with the parser. They
> really help one to get acquainted to HTMLParser.
> In particular, for your problem check out this example:
>
> org.htmlparser.parserapplications.LinkExtractor
>
> It tells you how to extract links. Then you should use the class
>
> org.htmlparser.filters.LinkStringFilter
>
> or
>
> org.htmlparser.filters.LinkRegexFilter
>
> to get only links containning the string "sony" or "jvc".
>
> Hope this helps you.
>
> On Feb 15, 2006, at 5:29 AM, vraja sekaran wrote:
>
> > Hi guys
> > I am new to HTML parser. I am trying to extract the
> > links that corresponds to a search string.
> > For example
> > <dd><a
> > href=3D"/Camcorders--reviews--brand_sony">Sony</a> <tt>(415)</
> > tt><dd><a
> > href=3D"/Camcorders--reviews--jvc">JVC</a> <tt>(385)</tt><dd><a
> >
> > .....
> >
> > In the above source code I want to extract the link
> > corresponding to Sony or JVC according to the
> > requirement.
> >
> > Thank you guys
> > Raj
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi=
les
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486&dat=
=3D121642
> _______________________________________________
> Htmlparser-user mailing list
> Htm...@li...
> https://lists.sourceforge.net/lists/listinfo/htmlparser-user
>
--
Naveen K Kohli
http://www.netomatix.com
|