From: Robert B. <rba...@ya...> - 2004-09-01 15:37:22
|
That is great, thanks. My problem is that I am using the 1.2.3 version and that does not seem to have this behavior. Do I have to move to the 1.3 pre-release? I am always hestitant to do this. The quick turn around on my issue is great, I really appreciate it. Thanks. --- Bruce Faulkner <Bru...@sa...> wrote: > In the current code for HtmlUnit (i.e. the 1.3 > pre-release code), the getAnchors() method of the > HtmlPage object does indeed return a list of HtmlAnchor > objects. > > The following code snippet was used to yield the results > below: > > List anchorList = page.getAnchors(); > for (Iterator iter = anchorList.iterator(); > iter.hasNext();) > { > HtmlAnchor anchor = (HtmlAnchor) iter.next(); > System.out.println("text: " + anchor.asText()); > System.out.println("href attribute: " + > anchor.getHrefAttribute()); > } > > text: some link name > href attribute: somelink > text: some link name 1 > href attribute: somelink1 > text: some link name 2 > href attribute: somelink2 > > where the input HTML page looked like: > > <html> > <body> > <a href="somelink">some link name</a> > <a href="somelink1">some link name 1</a> > <a href="somelink2">some link name 2</a> > </body> > </html> > > Hope this helps, > Bruce > -- > Bruce Faulkner > SAS Institute Inc. > > -----Original Message----- > From: htm...@li... > [mailto:htm...@li...] On > Behalf Of Robert Baccus > Sent: Wednesday, September 01, 2004 10:28 AM > To: htm...@li... > Subject: RE: [Htmlunit-user] Getting all the Anchor > (HTMLLinks) on a page? > > > Actually looking at the code below only returns the > Anchor objects not the HtmlAnchor objects. I already > looked at this and it didn't work for me. > > I am not sure that the HtmlLink object is what I am > looking for either since I am trying to get the following > <href a="somelink">some link name</a> in an object. I > want to capture the Somelink and SomeLinkName fields and > put them in a list. > > Thanks. > > > --- Bruce Faulkner <Bru...@sa...> wrote: > > > And, of course, if you really wanted the HtmlAnchor > objects rather > > than the HtmlLink objects, then it is even easier: > > > > List anchorList = myPage.getAnchors(); > > > > Bruce > > -- > > Bruce Faulkner > > SAS Institute Inc. > > > > -----Original Message----- > > From: htm...@li... > > [mailto:htm...@li...] On > Behalf Of Bruce > > Faulkner > > Sent: Wednesday, September 01, 2004 8:23 AM > > To: htm...@li... > > Subject: RE: [Htmlunit-user] Getting all the Anchor > (HTMLLinks) on a page? > > > > > > Something like the following code should give what you > need: > > > > List linkList = > > > myPage.getDocumentElement().getHtmlElementsByTagName(HtmlLink.TAG_NAME); > > Where myPage is an instance of an HtmlPage. > > > > Bruce > > -- > > Bruce Faulkner > > SAS Institute Inc. > > -----Original Message----- > > From: htm...@li... > > [mailto:htm...@li...] On > Behalf Of Robert > > Baccus > > Sent: Tuesday, August 31, 2004 8:13 PM > > To: htm...@li... > > Subject: [Htmlunit-user] Getting all the Anchor > (HTMLLinks) on a page? > > > > > > I noticed that HTMLUnit has the > HtmlPage.getFirstAnchorByText(String > > text) method. But what I am trying to accomplish is to > parse the > > whole page and pull out all of the HTMLLinks and put > them into a list. > > Can this easily be done? > > > > Thanks. > > > > ===== > > Rob Baccus > > Email: rb...@go... > > > > > > > > __________________________________ > > Do you Yahoo!? > > Read only the mail you want - Yahoo! Mail SpamGuard. > > http://promotions.yahoo.com/new_mail > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by BEA Weblogic Workshop > > FREE Java Enterprise J2EE developer tools! > > Get your free copy of BEA WebLogic Workshop 8.1 today. > > http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click > > _______________________________________________ > > Htmlunit-user mailing list > Htm...@li... > > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by BEA Weblogic Workshop > > FREE Java Enterprise J2EE developer tools! > > Get your free copy of BEA WebLogic Workshop 8.1 today. > > http://ads.osdn.com/?ad_idP47&alloc_id808&op=ick > > _______________________________________________ > > Htmlunit-user mailing list > Htm...@li... > > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by BEA Weblogic Workshop > > FREE Java Enterprise J2EE developer tools! > > Get your free copy of BEA WebLogic Workshop 8.1 today. > > http://ads.osdn.com/?ad_idP47&alloc_id808&op=click > > _______________________________________________ > > Htmlunit-user mailing list > Htm...@li... > > > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > > > ===== > Rob Baccus > Email: rb...@go... > > > > _______________________________ > Do you Yahoo!? > Express yourself with Y! Messenger! Free. Download now. > http://messenger.yahoo.com > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_idP47&alloc_id808&op=click > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > ===== Rob Baccus Email: rb...@go... _______________________________ Do you Yahoo!? Win 1 of 4,000 free domain names from Yahoo! Enter now. http://promotions.yahoo.com/goldrush |