0

I'm using HtmlUnit to navigate site and get some info. The code perfectly work at home via wi-fi router, but can't access internet at office (via LAN) without any Exception, it's just nothing happen.

This is part of my code:

public class WebParser {
public static void main(String[] args) {
    try {
    WebClient webClient = new WebClient();
    HtmlPage page =    webClient.getPage("http://rmpnovo.ru/spardeck/main.asp");
    System.out.println(page.asText());
    }
    catch (Exception e) {
    JOptionPane.showMessageDialog(null, e) }
}}

Or with proxy:

public class WebParser {
public static void main(String[] args) {
    try {
    WebClient webClient = new WebClient();
    webClient.setProxyConfig(new ProxyConfig("***.***.*.*", ****));
    HtmlPage page =    webClient.getPage("http://rmpnovo.ru/spardeck/main.asp");
    System.out.println(page.asText());
    }
    catch (Exception e) {
    JOptionPane.showMessageDialog(null, e) }
}}

Same problem was with URLConnection, but was resolved using proxy like:

Proxy proxy = new Proxy(Proxy.Type.HTTP, new    InetSocketAddress("***.***.*.*", ***));
URLConnection conn = new URL("some_site").openConnection(proxy);

Any advise how to solve this issue will be appreciated.

0 Answers0