From: Stephen P. <st...@lo...> - 2016-03-08 19:19:37
|
AT LONG LAST... This works: public static void main(String[] args) throws Exception{ try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF); System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); String url = "http://www.bhphotovideo.com/c/search?Ntt=kas-"; HtmlPage page = webClient.getPage(url); List<DomNode> nodeProduct = (List<DomNode>) page.getByXPath("//*[@data-selenium='itemDetail']"); if (nodeProduct.size() > 0) { for (DomNode e : nodeProduct) { List<DomNode> b = (List<DomNode>) e.getByXPath(".//*[@itemprop='brand']"); List<DomNode> n = (List<DomNode>) e.getByXPath(".//*[@itemprop='name']"); List<DomNode> p = (List<DomNode>) e.getByXPath(".//*[@data-selenium='price']"); System.out.println(b.get(0).getTextContent() + " / " + n.get(0).getTextContent() + " / " + p.get(0).getTextContent().trim()); } } } } OUTPUT: run: Kino Flo / KAS-D2-C Diva-Lite 200 Travel Case / $218.63 Canon / CN7x17 KAS S Cine-Servo 17-120mm T2.95 (PL Mount) / $29,850.00 Canon / CN7x17 KAS S Cine-Servo 17-120mm T2.95 (EF Mount) / $29,850.00 Kino Flo / KAS-CL6 6-Lamp Carry Case / $45.38 Kino Flo / KAS-D42 Diva-Lite 400 Wheeled Flight Case - for Two each Kino-Flo Diva-Lite 400 Fixtures, Stands, Mounts, Flozier and Lamp Cases / $483.00 Kino Flo / KAS-CE2 Flight Case (Yellow) / $371.25 Kino Flo / KAS-CE2-C Clamshell Travel Case (Yellow) / $288.75 Kino Flo / KAS-D4-C Diva-Lite 400 Travel Case - for Kino Flo Diva-Lite 400 Lighting Kit / $282.00 Kino Flo / KAS-GAF2 Gaffer Kit Ship Case / $536.25 Kino Flo / KAS-V31-Y Yoke Shipping Case - for VistaBeam 300 Fluorescent Fixture with Yoke Mount / $649.95 Kino Flo / KAS-V61-Y Yoke Shipping Case - for VistaBeam 600 Fluorescent Fixture with Yoke Mount / $881.95 Kino Flo / KAS-24S Telescoping Shipping Case, Small - for up to three Kino-Flo 2.0' Fixtures / $136.13 Kino Flo / KAS-41 Telescoping Shipping Case - for 1 Kino-Flo 4' Bank System / $212.50 Kino Flo / KAS-CE2-Y Yoke Ship Case (Black) / $433.13 Kino Flo / KAS-D22 Diva-Lite 200 Flight Case - for Two each Kino-Flo Diva-Lite 200 Fixtures, Stands, Mounts, Flozier and Lamp Cases / $441.95 Kino Flo / KAS-B4-C Clamshell Travel Case for One BarFly 400D Kit (Black) / $325.88 Kino Flo / KAS-B41 BarFly 400 Ship Case / $488.75 Kino Flo / KAS-D4-CS Diva-Lite 401 Travel Case / $325.88 Kino Flo / KAS-INT2 Interview Ship Case / $474.38 Kino Flo / KAS-INT3 Interview Ship Case / $489.88 Kino Flo / KAS-V31 Center Shipping Case - for VistaBeam 300 Fluorescent Fixture with Center Mount / $629.95 Kino Flo / KAS-V61 Center Shipping Case - for VistaBeam 600 Fluorescent Fixture with Center Mount / $827.50 Kino Flo / KAS-V62 Center Shipping Case - for Two VistaBeam 600 Fluorescent Fixtures with Center Mount / $1,133.95 Kino Flo / KAS-VH2 Vista Single Louver Carry Case / $45.95 BUILD SUCCESSFUL (total time: 5 seconds) Ahmed, I question why the implementation of getByXPath is demanding I use the wildcards for the searches instead of being able to specify the elements. But, for now, as long as it works, I'm going to run with it. Thank you all for the input and suggestions. ~ Steve ----- Stephen M. Paulsen Lowing Light & Grip |