i new htmlunit , not know how read , understand page source of website. nonetheless, have written code (learned tutorial) try , access following website
then stuck, not familiar javascript. want achieve:
i type
328
in textfield on left menu on websiteand click submit button
so can brought next page.
update: managed resolve page access problem adding line code. still having trouble locate input text field, type in input , click button, can landed next page.
public void testing() throws exception { /* turn off annoying htmlunit warnings */ java.util.logging.logger.getlogger("com.gargoylesoftware").setlevel(java.util.logging.level.off); try (final webclient webclient = new webclient(browserversion.chrome)) { final htmlpage page = webclient.getpage("http://www.aastocks.com/en/stock/detailquote.aspx?&symbol=1"); final htmldivision div = page.gethtmlelementbyid("leftmenu_button"); } }
the website has css url //:
, wasn't correctly handled htmlunit, , fixed in svn.
please latest build, below code works:
try (final webclient webclient = new webclient(browserversion.chrome)) { final htmlpage page = webclient.getpage("http://www.aastocks.com/en/stock/detailquote.aspx?&symbol1"); htmlinput input = page.gethtmlelementbyid("py_txt"); input.type("328"); final htmlpage page2 = page.gethtmlelementbyid("imghkstocksubmit").click(); system.out.println(page2.geturl()); system.out.println(page2.astext()); }
Comments
Post a Comment