BAEL-3842 : How to add proxy support to Jsoup (#9202)

This commit is contained in:
Roque Santos 2020-05-04 13:37:38 -03:00 committed by GitHub
parent b3f1413445
commit ab9e0e164f
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
package com.baeldung.jsonproxy;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import org.jsoup.Jsoup;
import org.junit.Test;
public class JsoupProxyIntegrationTest {
@Test
public void whenUsingHostAndPort_thenConnect() throws IOException {
Jsoup.connect("https://spring.io/blog")
.proxy("200.216.227.141", 53281)
.get();
}
@Test
public void whenUsingProxyClass_thenConnect() throws IOException {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("200.216.227.141", 53281));
Jsoup.connect("https://spring.io/blog")
.proxy(proxy)
.get();
}
}