htmlunit

HtmlUnit Javascript error when getting Page

可紊 提交于 2019-12-11 11:12:03
问题 I'm new to interacting with websites in Java, and I am having trouble getting a webpage with htmlUnit 2.18. I've tried to change the URL to other websites(like google), and those pages have loaded. But when I try to load the page my program needs I get the attached errors. I've steped through my program and it is breaking on the line final HtmlPage loginPage = browser.getPage(LOGIN_PAGE); Java File: import java.io.IOException; import java.net.MalformedURLException; import com.gargoylesoftware

importing HtmlUnit to Android project

流过昼夜 提交于 2019-12-11 10:47:13
问题 I downloaded the htmlunit-2.xx-OSGi.jar from htmlunit sourceforge page. Moved that jar into my /lib folder and when I import these I get error. import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; ERROR: Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non

Running HtmlUnit in C#?

家住魔仙堡 提交于 2019-12-11 10:40:10
问题 I'm trying to run HtmlUnit using Selenium WebDriver in C#. When I run the following code (which as I understand it should start the HtmlUnit webdriver): var caps = DesiredCapabilities.HtmlUnit(); IWebDriver driver = new RemoteWebDriver(caps); I get the exception: Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:4444 As far as I'm

Determine used libraries to reduce JAR file size

随声附和 提交于 2019-12-11 07:28:41
问题 I am using HtmlUnit in some programs and I always have the problem that whenever I use it, I have to add all the files (libraries) that I downloaded from HtmlUnit website so the jar file that I get is always 10 mb. These are the files that I add: But in most of my programs I only include this: import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.RefreshHandler; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.*; I usually

How to submit file in form with HtmlUnit

回眸只為那壹抹淺笑 提交于 2019-12-11 06:42:36
问题 I have a problem with this form <form action="/incoming/Upload.cfg" enctype="multipart/form-data" method="post" onsubmit="return doSubmit();"> <table id="autoWidth" border="0" style="width: 100%;"> <tbody> <tr> <td class="h1" colspan="4" id="t_title"> Резервная копия и Восстановление </td> </tr> <tr> <td class="blue" colspan="4"/> </tr> <tr> <td class="Item" id="t_backup"> Сохранить: </td> <td colspan="3"> <input type="button" class="buttonBigL" name="Backup" value="Резервная копия" onclick=

How to filter javascript from specific urls in HtmlUnit

若如初见. 提交于 2019-12-11 04:57:42
问题 HtmlUnit takes lot of time to execute javascript, i would like to know if its possible to make HtmlUnit not to load javascript from url regex filters. 回答1: Not exactly, you can't only disable javascript as a whole (probably you already know it): final WebClient webClient = new WebClient(); webClient.getOptions().setJavascriptEnable(false); but you can use a ScriptPreProcessor the javascript, and erase what you don't want: webClient.setScriptPreProcessor(new ScriptPreProcessor() { @Override

HtmlAnchor click() function in Htmlunit is not working

送分小仙女□ 提交于 2019-12-11 03:59:37
问题 I am trying to use HtmlUnit for browsing automatically a site. I need to press some buttons in the process. First I build an HtmlAnchor object of a button with this xml: <a href="dog.php"> <img src="http://images.hand.co.uk/Pic/site_images/hand/Myper/MyOrder/images/DogRed.gif" width="75" height="31" border="0" alt="1 adds"/> </a> which works fine when I click it using the click() method. I am then moved to another page in which I have link on which I need to click for the desired contents to

How can I disable or specify the number of retries in HtmlUnit (java)?

假如想象 提交于 2019-12-11 03:11:49
问题 I want, that a web request in HtmlUnit is not executed again after a connection reset.The following exception message shows the retrying connect: INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Connection reset * * org.apache.http.impl.client.DefaultRequestDirector tryConnect INFO: Retrying connect So how can I disable or specify the number of retries in HtmlUnit (java)? 回答1: Because of how the classes are structured, I have been working with this. I

Error while using HtmlUnit

好久不见. 提交于 2019-12-11 02:42:51
问题 When I execute this simple code to get the contents of a website as text, it shows errors which I can't understand. import java.io.IOException; import java.net.MalformedURLException; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.ScriptException; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; public class sd { public static void main(String[] args) { sd vip=new sd(); try { vip

How to get base64 encoded contents for an ImageReader?

若如初见. 提交于 2019-12-11 02:26:18
问题 How do I read an image into a base64 encoded string by its ImageReader ? Here's example source code using HtmlUnit. I want to get the base64 String of img : WebClient wc = new WebClient(); wc.setThrowExceptionOnFailingStatusCode(false); wc.setThrowExceptionOnScriptError(false); HtmlPage p = wc.getPage("http://flickr.com"); HtmlImage img = (HtmlImage) p.getByXPath("//img").get(3); System.out.println(img.getImageReader().getFormatName()); 回答1: The HtmlUnit's HtmlImage#getImageReader() returns