List of usage examples for java.net CookiePolicy ACCEPT_ALL
CookiePolicy ACCEPT_ALL
To view the source code for java.net CookiePolicy ACCEPT_ALL.
Click Source Link
From source file:jmc.util.UtlFbComents.java
public static void getComentarios(Long idContenido, Long numComents) throws JMCException { File f = null;//from w ww .java2 s. co m try { Properties props = ConfigPropiedades.getProperties("props_config.properties"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); URL ur = new URL("http://graph.facebook.com/comments?id=" + Contenido.getContenido("Where cont_id = '" + idContenido + "'").get(0).getEnlaceURL() + "&limit=" + numComents + "&filter=stream"); HttpURLConnection cn = (HttpURLConnection) ur.openConnection(); cn.setRequestProperty("user-agent", props.getProperty("navegador")); cn.setInstanceFollowRedirects(false); cn.setUseCaches(false); cn.connect(); BufferedReader br = new BufferedReader(new InputStreamReader(cn.getInputStream())); String dirTempHtml = props.getProperty("archive_json") + "/"; File fld = new File(dirTempHtml); boolean creado = fld.exists() ? true : fld.mkdir(); if (creado) { String archFile = idContenido + ".json"; String archivo = dirTempHtml + archFile; String linea = null; f = new File(archivo); BufferedWriter bw = new BufferedWriter(new FileWriter(f)); while ((linea = br.readLine()) != null) { bw.append(linea); } bw.close(); cn.disconnect(); List<Fbcoment> lfb = Convertidor.getFbcomentObjects(idContenido, archivo); Fbcoment.actComents(idContenido, lfb); } else { cn.disconnect(); } } catch (IOException e) { throw new JMCException(e); } }
From source file:gmusic.api.comm.HttpUrlConnector.java
public HttpUrlConnector() { CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); }
From source file:horriblev3.Cloudflare.java
public List<HttpCookie> scrape() { if (strUrl == null) { System.out.println("URL == NULL"); return null; }//from w w w. ja v a 2s . c om try { CookieManager manager = new CookieManager(); manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(manager); URL url = new URL(strUrl); HttpURLConnection con; con = (HttpURLConnection) url.openConnection(); con.setRequestProperty("User-Agent", USERAGENT); InputStream _is; if (con.getResponseCode() == 200) { return retrieveCookies(manager); } else { _is = con.getErrorStream(); StringBuilder result = new StringBuilder(); try (BufferedReader rd = new BufferedReader(new InputStreamReader(_is))) { String line; while ((line = rd.readLine()) != null) { result.append(line); } } String source = result.toString(); //extract challenge String challenge = regex(source, "name=\"jschl_vc\" value=\"(\\w+)\""); String challenge_pass = regex(source, "name=\"pass\" value=\"(.+?)\""); //prepare String builder = regex(source, "setTimeout\\(function\\(\\)\\{\\s+(var s,t,o,p,b,r,e,a,k,i,n,g,f.+?\\r?[\\s\\S]+?a\\.value =.+?)\\r?\\s+';"); builder = builder.replaceFirst("\\s{3,}[a-z](?: = ).+form'\\);\\s+;", "").replaceFirst( "a\\.value = parseInt\\(.+?\\).+", regex(builder, "a\\.value = (parseInt\\(.+?\\)).+")); //Execute&solve System.out.println(builder); long solved = Long.parseLong(solveJS2(builder)); solved += url.getHost().length(); System.out.println("SOLVED: " + solved); try { Thread.sleep(3000); } catch (InterruptedException e) { System.out.println(e.getMessage()); } URI tmp = UrlToUri(url); List<NameValuePair> qparams = new ArrayList<>(); qparams.add(new BasicNameValuePair("jschl_vc", challenge)); qparams.add(new BasicNameValuePair("jschl_answer", String.valueOf(solved))); qparams.add(new BasicNameValuePair("pass", challenge_pass)); URIBuilder uriBuilder = new URIBuilder().setScheme(tmp.getScheme()).setPath("/cdn-cgi/l/chk_jschl") .setHost(tmp.getHost()).setParameters(qparams); HttpURLConnection cookie_req = (HttpURLConnection) new URL(uriBuilder.toString()).openConnection(); cookie_req.setRequestProperty("Referer", url.toString()); cookie_req.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0"); HttpURLConnection.setFollowRedirects(false); cookie_req.connect(); System.out.println("ResponseCode: " + cookie_req.getResponseCode()); if (cookie_req.getResponseCode() == 200) { return retrieveCookies(manager); } else { System.out.println("Something went wrong!"); return null; } } } catch (IOException e1) { System.out.println(e1.getMessage()); return null; } }
From source file:net.qiujuer.common.okhttp.Http.java
public static void enableSaveCookie(Context context) { getClient()//from ww w . j a va 2s . c o m .setCookieHandler(new CookieManager(new PersistentCookieStore(context), CookiePolicy.ACCEPT_ALL)); }
From source file:fr.cph.stock.android.web.Connect.java
protected Connect() { this.cookieManager = new CookieManager(null, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(cookieManager); this.client = new MyHttpClient(); }
From source file:com.jaspersoft.android.jaspermobile.network.cookie.CookieHandlerFactory.java
@NonNull public CookieHandler newStore(@NonNull Context context) { WebViewCookieStore webViewCookieStore = createWebViewCookieStore(context); java.net.CookieStore cookieStore = new PersistentCookieStore(context); CookieMapper cookieMapper = new CookieMapper(); org.apache.http.client.CookieStore apacheStore = new ApacheCookieStore(cookieStore, cookieMapper); AppCookieStore appCookieStore = new AppCookieStore(webViewCookieStore, cookieStore, apacheStore); CookieHandler defaultCookieManager = new CookieManager(appCookieStore, CookiePolicy.ACCEPT_ALL); CookieHandler.setDefault(defaultCookieManager); return defaultCookieManager; }
From source file:com.example.administrator.datarequest.ningworld.NoHttp.java
/** * Initialization NoHttp, Should invoke on {@link Application#onCreate()}. * * @param application {@link Application}. *//*from www .ja va2s . c om*/ public static void init(Application application) { if (sApplication == null) { sApplication = application; PRNGFixes.apply(); sCookieHandler = new CookieManager(DiskCookieStore.INSTANCE, CookiePolicy.ACCEPT_ALL); } }
From source file:com.jamfsoftware.jss.healthcheck.controller.HTTPController.java
public String doGet(String URL) throws Exception { CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); URL obj = new URL(URL); //Relax host checking for Self Signed Certs HttpURLConnection con = (HttpURLConnection) obj.openConnection(); TrustModifier.relaxHostChecking(con); //Setup the Connection. con.setRequestMethod("GET"); con.setRequestProperty("User_Agent", USER_AGENT); Base64 b = new Base64(); String encoding = b.encodeAsString((username + ":" + password).getBytes()); con.setRequestProperty("Authorization", "Basic " + encoding); int responseCode = con.getResponseCode(); LOGGER.debug("Sending 'GET' request to URL : " + URL); LOGGER.debug("Response Code : " + responseCode); //Get the response BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine;/*w ww.j av a 2 s . c o m*/ StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); return response.toString(); }
From source file:jmc.util.UtlFbComents.java
public static void getURLComentarios(String url, Long numComents) throws JMCException { File f = null;// w w w .j a va2 s .c om try { Properties props = ConfigPropiedades.getProperties("props_config.properties"); CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL)); URL ur = new URL( "http://graph.facebook.com/comments?id=" + url + "&limit=" + numComents + "&filter=stream"); HttpURLConnection cn = (HttpURLConnection) ur.openConnection(); cn.setRequestProperty("user-agent", props.getProperty("navegador")); cn.setInstanceFollowRedirects(false); cn.setUseCaches(false); cn.connect(); BufferedReader br = new BufferedReader(new InputStreamReader(cn.getInputStream())); String dirTempHtml = props.getProperty("archive_json") + "/"; File fld = new File(dirTempHtml); boolean creado = fld.exists() ? true : fld.mkdir(); if (creado) { String archFile = "archivo.json"; String archivo = dirTempHtml + archFile; String linea = null; f = new File(archivo); BufferedWriter bw = new BufferedWriter(new FileWriter(f)); while ((linea = br.readLine()) != null) { bw.append(linea); } bw.close(); cn.disconnect(); List<Fbcoment> lfb = Convertidor.getFbcomentObjects(1l, archivo); // Fbcoment.actComents(idContenido, lfb); } else { cn.disconnect(); } } catch (IOException e) { throw new JMCException(e); } }