Jump to content

java HttpCLient


emanuelx
 Share

Recommended Posts

boas, pessoal estou a aqui a tentar fazer uma coisa mas não sei se é possível.

A questão é a seguinte, é possível eu ler 1º a página html, com o HttpClient e logo depois enviar alguns parametros lidos da pagina pelo metodo POST?

sem que a página expire?

com calma e sem stresses

Link to comment
Share on other sites

fica aqui o codigo que desenvolvi mas não funciona, eu usei o wireshark e os parametros são iguais, da forma que este codigo trabalha bem como o funcionamento do site, deve de haver alguma forma para dar a volta a este problema.

private static void beststreams( String url_) throws MalformedURLException, IOException
  {
  // op=download1&usr_login=&id=76ihyyinvpqw&fname=The.Wolf.of.Wall.Street.2013.DVDSCR.mkv&referer=http%3A%2F%2Fbestreams.net%2F76ihyyinvpqw&hash=409654-2-83-1395183245-201aada5926d2af46add91de063158cd&imhuman=Proceed+to+video
  // String find = sourcecode(url_);
   HttpClient Client = new DefaultHttpClient(); //new client
   //set user agent
    Client.getParams().setParameter(CoreProtocolPNames.USER_AGENT,"Mozilla/4.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36");
 //acess web site by method get
 HttpGet httpget = new HttpGet(url_);
   // get response
 HttpResponse  responses =  Client.execute(httpget);
  HttpEntity respEntitys = responses.getEntity();
  //get html from page
  String contents =  EntityUtils.toString(respEntitys);
  //System.out.println(contents);
   String find = contents;
   //get important elements from html
   //op
   String op = find.substring(find.indexOf("name=\"op\""));
  // System.out.println("op1" +op);

   op = op.substring(op.indexOf("value=\"") +7,op.indexOf("\">"));
   System.out.println("op " +op);
   String id = find.substring(find.indexOf("name=\"id\""));

   //id
   id = id.substring(id.indexOf("value=\"") +7,id.indexOf("\">"));
  System.out.println(id);
   //fname
   String fname = find.substring(find.indexOf("name=\"fname\""));
   fname =  fname.substring(fname.indexOf("value=\"") +7,fname.indexOf("\">"));
   System.out.println(fname);
   //hash
   String hash = find.substring(find.indexOf("name=\"hash\""));
    hash =  hash.substring(hash.indexOf("value=\"") +7,hash.indexOf("\">"));
   System.out.println(hash);

  /* String url_final = url_ + "?op=" + op + "&usr_login=&id=" + id + "&fname=" +fname + "&referer="+ url_ + "&hash=" + hash + "&imhuman=Proceed+to+video";
  System.out.println(url_final);*/


  //Client.getParams().setParameter(CoreProtocolPNames.USER_AGENT,"Mozilla/4.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36");
   //create a httpPOst
HttpPost httpPost = new HttpPost(url_);
//send elements to POST
  List<NameValuePair> params = new ArrayList<NameValuePair>();
  //elements retirados do html do site - codigo anterior
  params.add(new BasicNameValuePair("op", op));
  params.add(new BasicNameValuePair("usr_login", ""));
  params.add(new BasicNameValuePair("id", id));
  params.add(new BasicNameValuePair("fname", fname));
  params.add(new BasicNameValuePair("referer", URLEncoder.encode(url_,"UTF-8")));
  params.add(new BasicNameValuePair("hash", hash));
  params.add(new BasicNameValuePair("imhuman", "Proceed+to+video"));
  httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
 HttpResponse  response = Client.execute(httpPost);
  System.out.println("respse" + response.toString());
 HttpEntity respEntity = response.getEntity();
 //get html of page
  String content =  EntityUtils.toString(respEntity);
  System.out.println(content);

  }

cumps

com calma e sem stresses

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.