Android Studio, This site requires Javascript to work, please enable Javascript in your browser, server passing html values “Checking your browser” with JSON String

print

Problem when you are getting json from some sites that needs

Response string

function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e=””,f=0;fd[f]?”0″:””)+d[f].toString(16);return e.toLowerCase()}var a=toNumbers(“f655ba9d09a112d4968c63579db590b4”),b=toNumbers(“98344c2eee86c3994890592585b49f80”),c=toNumbers(“99efa97c59e1cf6146f7e801802ed6bc”);document.cookie=”__test=”+toHex(slowAES.decrypt(c,2,a,b))+”; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/”; document.cookie=”referrer=”+escape(document.referrer); location.href=”http://zsoft.byethost8.com/login.php?ckattempt=1″;This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support
function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;fd[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("99efa97c59e1cf6146f7e801802ed6bc");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; document.cookie="referrer="+escape(document.referrer); location.href="http://zsoft.byethost8.com/login.php?ckattempt=1";This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support

https://kyprizel.github.io/testcookie-nginx-module/

I solved like as Sebastian Mora answers  here https://stackoverflow.com/questions/31912000/byethost-server-passing-html-values-checking-your-browser-with-json-string

 

  • Getting the cookie key from the web browser. I used Google Chrome for it:
    1. From the Chrome menu in the top right corner of the browser, select Settings.
    2. At the bottom of the page, click Show advanced settings….
    3. Under Privacy, select Content settings….
    4. select All cookies and site data….
    5. Search for you website name. By searching “byethost” you’ll find it.
    6. Open the cookie named __test and copy the values of content, path and expires
  • Setting the cookie on our Android app. On your code should be something like:

 

try
{
if(post == "POST")
{
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(loginUrl);
httpPost.setEntity(new UrlEncodedFormEntity(para));
httpPost.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240 ");
httpPost.addHeader("Cookie", "__test=THE_CONTENT_OF_YOUR_COOKIE_HERE; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
else if(post == "GET")
{
HttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(para, "utf-8");
loginUrl += "?" + paramString;
HttpGet httpGet = new HttpGet(loginUrl);
httpGet.addHeader("Cookie", "__test=THE_CONTENT_OF_YOUR_COOKIE_HERE; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/");
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
}

 

My Solution

connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240 ");
connection.setRequestProperty("Cookie", "__test=2ad4957fd60a8b74775f11b309b4496a; expires=Friday, 1 January 2038 at 01:55:55; path=/");//other any other

3 thoughts on “Android Studio, This site requires Javascript to work, please enable Javascript in your browser, server passing html values “Checking your browser” with JSON String”

  1. I had this same issue when i am creating a registration form in my android app.Where we have to place this android code?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.