htmlunit

Htmlunit : filling a form that refreshes automatically

被刻印的时光 ゝ 提交于 2019-12-07 15:46:07
问题 I can normally fill-in a form using an HtmlUnit and submit it to the server. Fine. UnfortunateIy I don't know how to fill-in a specific form that refreshes to server depening on values I set on the form. That form seems to refreshes to the server because of some javascript that is triggered when a value is set for a field... To make a simple example, I have a form with 2 fields, drop-down lists, let's say Country and Region: when I choose a value from field Country, the page automatically

Cookie policy in htmlunit

霸气de小男生 提交于 2019-12-07 14:37:11
问题 How do you specify a cookie policy in htmlunit to accept all cookies? 回答1: Just recreate the whole CookieManager class: Here is source of the class: http://jarvana.com/jarvana/view/net/sourceforge/htmlunit/htmlunit/2.8/htmlunit-2.8-sources.jar!/com/gargoylesoftware/htmlunit/CookieManager.java?format=ok Now lookup this method public synchronized Set<Cookie> getCookies(final URL url) in there you find this: public static final String HTMLUNIT_COOKIE_POLICY = CookiePolicy.BROWSER_COMPATIBILITY;

HTMLunit - Facebook Login

谁说胖子不能爱 提交于 2019-12-07 13:57:43
问题 final WebClient webClient = new WebClient(); webClient.setJavaScriptEngine(new JavaScriptEngine(webClient)); HtmlPage page1 = null; try { page1 = webClient.getPage("http://www.facebook.com"); } catch (IOException e) { e.printStackTrace(); } final HtmlForm form = (HtmlForm) page1.getElementById("login_form"); final HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue("Log In").get(0); final HtmlTextInput textField = (HtmlTextInput) page1.getElementById("email"); textField

Clicking on javascript anchor with htmlunit does not seem to work

ε祈祈猫儿з 提交于 2019-12-07 11:17:36
问题 I am using htmlunit to automatically go through a website. Here is the problem: I want to click on an anchor in order to display a new page of a given table. Here is the anchor: <a href="javascript:__doPostBack('GridView1','Page$7')">7</a> Here is my code: final HtmlAnchor a = page2.getAnchorByText("7"); HtmlPage page3 = a.click(); System.out.println(page2.getWebResponse().getContentAsString()) System.out.println(page3.getWebResponse().getContentAsString()); I do not have any error message.

Ajax Crawling on Google App Engine - Does HtmlUnit work?

我只是一个虾纸丫 提交于 2019-12-07 10:08:32
问题 http://code.google.com/web/ajaxcrawling/docs/html-snapshot.html Does HtmlUnit work on AppEngine? If not, are there any other ways to make my GWT app crawlable by search engines? 回答1: A patch for HtmlUnit to work on GAE is in progress. HtmlUnit's bug tracker issue 2962074 discusses making HtmlUnit work on GAE, and provides a preliminary patch for accomplishing this. 回答2: it doesn't work on the last GAE version (even after patch applying) to check the post http://groups.google.com/group/google

HtmlUnit can't get the js / ajax added of IFRAME

拥有回忆 提交于 2019-12-07 09:21:30
问题 I've just started learning htmlunit by gargoylesoftware and I have a problem. There is an iframe on a page, which appears after a button click. When i try to get this iframe by name I get a ElementNotFoundException . Also I tried page.getFrames() and it returns frames, but there is no frame that i'm looking for or it is blank. So It looks like js/ajax didn't update it. I work on jcpenny(dot)com and problem appears when I try to "checkout" from "My Bag" page Here is my WebClient settings

HtmlUnit not creating HtmlPage object

大兔子大兔子 提交于 2019-12-07 08:52:16
问题 I'm very new to HtmlUnit and I'm trying to scrape a website that uses Javascript to edit the code. I heard HtmlUnit was the best way to go as it returns the final code using a headless browser. However as you will see I cannot even get past creating a HtmlPage object without getting a huge and impossible to understand exception thrown (at least given my virtually null experience with HtmlUnit). Here is my code: import com.gargoylesoftware.htmlunit.*; import com.gargoylesoftware.htmlunit.html

HtmlUnit Exception

混江龙づ霸主 提交于 2019-12-07 07:56:40
问题 I am having trouble understanding the meaning of this HTMLUnit Exception. It happens when I call click() on a link on a webpage. Exception class=[net.sourceforge.htmlunit.corejs.javascript.WrappedException] com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "offsetWidth" from null (http://webapps6.doc.state.nc.us/opi/scripts/DHTMLmessages.js#95) (javascript url#297) at com.gargoylesoftware.htmlunit.javascript

HTMLUNIT getformbyname with no form name specified in the website

穿精又带淫゛_ 提交于 2019-12-07 00:45:17
问题 I'm trying to clcik a button on a website using HTMLUNIT i followed this tutorial http://htmlunit.sourceforge.net/gettingStarted.html but it requires a form name. The website I'm trying to do has this page source. <form method="post" action="doDelete"> Are you sure you want to delete 'Apple?'? <input name="Submit" value="Yes" class="submit-button" type="submit" /> </form> I'm trying to click the "Yes" button validation box on the webpage.(Delete Valdation) As you can see there is no form name

unable to run Htmlunit application using Maven dependency

倖福魔咒の 提交于 2019-12-07 00:38:37
I have added Htmlunit Maven dependency by adding the following to my pom.xml <dependency> <groupId>net.sourceforge.htmlunit</groupId> <artifactId>htmlunit</artifactId> <version>2.18</version> </dependency> When I am trying to run the application, I am getting the following error: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/ssl/NoopHostnameVerifier at com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.buildSSLSocketFactory(HtmlUnitSSLConnectionSocketFactory.java:112) at com.gargoylesoftware.htmlunit.HttpWebConnection