Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. private String GetPageContent(String url) throws Exception {
  2.  
  3. URL obj = new URL(url);
  4. conn = (HttpsURLConnection) obj.openConnection();
  5.  
  6. // default is GET
  7. conn.setRequestMethod("GET");
  8.  
  9. conn.setUseCaches(false);
  10.  
  11. // act like a browser
  12. conn.setRequestProperty("User-Agent", USER_AGENT);
  13. conn.setRequestProperty("Accept",
  14. "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
  15. conn.setRequestProperty("Accept-Language", "en-US,en;q=0.8,en-GB;q=0.6");
  16. conn.setRequestProperty("Accept-Encoding" , "gzip, deflate, sdch");
  17. conn.setRequestProperty("Connection" , "keep-alive");
  18.  
  19. if (cookies != null) {
  20. for (String cookie : this.cookies) {
  21. conn.addRequestProperty("Cookie", cookie.split(";", 1)[0]);
  22. }
  23. }
  24. int responseCode = conn.getResponseCode();
  25. Log.v(TAG,"nSending 'GET' request to URL : " + url);
  26. Log.v(TAG,"Response Code : " + responseCode);
  27.  
  28. BufferedReader in = new BufferedReader(new InputStreamReader(
  29. conn.getInputStream()));
  30. String inputLine;
  31. StringBuffer response = new StringBuffer();
  32.  
  33. while ((inputLine = in.readLine()) != null) {
  34. response.append(inputLine);
  35. }
  36. in.close();
  37.  
  38. // Get the response cookies
  39. setCookies(conn.getHeaderFields().get("Set-Cookie"));
  40.  
  41. return response.toString();
  42.  
  43. }
  44.  
  45. ��������������]�r�6��۞�w@ՙ�NDQ�ﱥ|�siv�Kkw�m&�HH�M, Z��ff_c_o�d�@���9�l�6����� �_=w|����/A{��!W� LZ��������f]�=wc߽�2,˨�|�8x��~�}�x1�$Ib�Uq�7�j�X|;��K
  46.  
  47. BufferedReader in = new BufferedReader(new InputStreamReader(
  48. new GZIPInputStream(conn.getInputStream())));
  49.  
  50. BufferedReader in = new BufferedReader(new InputStreamReader(
  51. conn.getInputStream(), "UTF8"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement