/** * Constructor for testing. * * @param s the response string * @param supportsUtf8 allow UTF-8 in response? * @since JavaMail 1.6.0 */ public Response(String s, boolean supportsUtf8) { if (supportsUtf8) buffer = s.getBytes(StandardCharsets.UTF_8); else buffer = s.getBytes(StandardCharsets.US_ASCII); size = buffer.length; utf8 = supportsUtf8; parse(); }
public Response(String s) { buffer = ASCIIUtility.getBytes(s); size = buffer.length; parse(); }
Response response = Jsoup.connect("http://example.com/login") .method(Method.POST) .data("username", username) .data("password", password) .data("login", "Login") .execute(); Map<String, String> cookies = response.cookies(); Document document = response.parse(); // If necessary. // ...
private Map<String, String> cookies = new HashMap<String, String>(); public Document get(url) throws IOException { Connection connection = Jsoup.connect(url); for (Entry<String, String> cookie : cookies.entrySet()) { connection.cookie(cookie.getKey(), cookie.getValue()); } Response response = connection.execute(); cookies.putAll(response.cookies()); return response.parse(); }
/** * Read a new Response from the given Protocol * * @param p the Protocol object * @exception IOException for I/O errors * @exception ProtocolException for protocol failures */ public Response(Protocol p) throws IOException, ProtocolException { // read one response into 'buffer' ByteArray ba = p.getResponseBuffer(); ByteArray response = p.getInputStream().readResponse(ba); buffer = response.getBytes(); size = response.getCount() - 2; // Skip the terminating CRLF parse(); }
/** * Read a new Response from the given Protocol * * @param p the Protocol object * @exception IOException for I/O errors * @exception ProtocolException for protocol failures */ public Response(Protocol p) throws IOException, ProtocolException { // read one response into 'buffer' ByteArray ba = p.getResponseBuffer(); ByteArray response = p.getInputStream().readResponse(ba); buffer = response.getBytes(); size = response.getCount() - 2; // Skip the terminating CRLF utf8 = p.supportsUtf8(); parse(); }
Response res = Jsoup.connect("url") .data("loginField", "yourUser", "passwordField", "yourPassword") .method(Method.POST) .execute(); Document doc = res.parse(); //If you need to keep logged in to the page, use Map<String, String> cookies = res.cookies; //And by every consequent connection, you'll need to use Document pageWhenAlreadyLoggedIn = Jsoup.connect("url").cookies(cookies).get();
Connection.Response res = Jsoup.connect("http://www.example.com/login.php") .data("username", "myUsername", "password", "myPassword") .method(Method.POST) .execute(); Document doc = res.parse();
// Jsoup-Connection Connection c = Jsoup.connect(urls[0]); // Request timeout in ms c.timeout(5000); Connection.Response r = c.execute(); Log.d("MyActivity","<r= doInBackground ("+urls[0]+")"); // Get the actual Document Document doc = r.parse(); Log.d("MyActivity","<d= doInBackground ("+urls[0]+")");
String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36"; String referer = "http://ecampus.smu.ac.kr/"; Connection.Response res = Jsoup.connect("https://ecampus.smu.ac.kr/login/index.php") .data(postMap) .userAgent(userAgent) .referrer(referer) .method(Connection.Method.POST) .execute(); Document doc = res.parse();
Connection.Response res = Jsoup.connect("http://example.org") .data("q", username, "password", password) .method(Method.GET) .execute(); Document doc = res.parse(); System.out.println(doc);
String encodedUrl = "http://xyo.net/iphone-app/instagram-RrkBUFE/"; Response res = Jsoup.connect(encodedUrl) .header("Accept-Language", "en") .ignoreHttpErrors(true) .ignoreContentType(true) .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") .followRedirects(true) .timeout(10000) .method(Connection.Method.GET) .execute(); System.out.println(res.parse());
public Response(String s) { buffer = ASCIIUtility.getBytes(s); size = buffer.length; parse(); }
public Response(String s) { buffer = ASCIIUtility.getBytes(s); size = buffer.length; parse(); }
import org.apache.commons.io.FileUtils; public void downloadPage() throws Exception { final Response response = Jsoup.connect("http://www.example.net").execute(); final Document doc = response.parse(); final File f = new File("filename.html"); FileUtils.writeStringToFile(f, doc.outerHtml(), "UTF-8"); }
FileInputStream fin = new FileInputStream(management.getFilePath()); KeyStore ks = KeyStore.getInstance(management.getSSLProtocol()); ks.load(fin, management.getPassword().toCharArray()); System.setProperty("javax.net.ssl.keyStore", "certificate.jks"); System.setProperty("javax.net.ssl.keyStorePassword", management.getPassword()); Connection.Response res = Jsoup.connect(management.getHomeURL()). timeout(5000).ignoreHttpErrors(true).followRedirects(true).execute(); res = Jsoup.connect(management.getHomeURL()).timeout(5000).execute(); Document post = res.parse(); System.out.println(post.html());
String loginURL = "https://investorshub.advfn.com/boards/login.aspx" Connection.Response response = Jsoup.connect(loginURL) .method(Connection.Method.GET) .execute(); Document loginPage = response.parse(); Document document = Jsoup.connect(loginURL) .data("ctl00$CP1$LoginView1$Login1$UserName", "Myusername") .data("ctl00$CP1$LoginView1$Login1$Password", "Mypassword") .data("ctl00$CP1$LoginView1$Login1$LoginButton", "Log In") .data("__VIEWSTATE", loginPage.getElementById("__VIEWSTATE").val()) .cookies(response.cookies()) .post();
/** * Read a new Response from the given Protocol * @param p the Protocol object */ public Response(Protocol p) throws IOException, ProtocolException { // read one response into 'buffer' ByteArray ba = p.getResponseBuffer(); ByteArray response = p.getInputStream().readResponse(ba); buffer = response.getBytes(); size = response.getCount() - 2; // Skip the terminating CRLF parse(); }
/** * Read a new Response from the given Protocol * @param p the Protocol object */ public Response(Protocol p) throws IOException, ProtocolException { // read one response into 'buffer' ByteArray ba = p.getResponseBuffer(); ByteArray response = p.getInputStream().readResponse(ba); buffer = response.getBytes(); size = response.getCount() - 2; // Skip the terminating CRLF parse(); }