Java simulation Landing for yourself to see

Source: Internet
Author: User

Package Denglu;import Java.io.ioexception;import java.util.arraylist;import java.util.list;import Org.apache.http.httpentity;import Org.apache.http.httpresponse;import Org.apache.http.client.clientprotocolexception;import Org.apache.http.client.httpclient;import Org.apache.http.client.methods.httpget;import Org.apache.http.client.methods.httppost;import Org.apache.http.impl.client.defaulthttpclient;import Org.apache.http.util.entityutils;import Org.apache.http.namevaluepair;import Org.apache.http.client.entity.urlencodedformentity;import Org.apache.http.message.BasicNameValuePair; Public classTset { Public  voidShiyan () throws Clientprotocolexception, ioexception{//Get page InformationHttpClient HttpClient =Newdefaulthttpclient (); HttpGet HttpGet=NewHttpGet ("http://192.168.33.160:8088/login.html"); HttpResponse Response=Httpclient.execute (HttpGet); Httpentity Entity=response.getentity (); String HTML= Entityutils.tostring (Entity,"GBK");     Httpget.releaseconnection (); System. out. println (HTML);} Public voidlogin () throws Clientprotocolexception, ioexception{httppost httppost=NewHttpPost ("http://192.168.33.160:8088/login.html"); List<NameValuePair>params=NewArraylist<namevaluepair>(); params. Add (NewBasicnamevaluepair ("name","Admin")); params. Add (NewBasicnamevaluepair ("Password","Admin")); Httppost.setentity (NewUrlencodedformentity (params)); HttpClient HttpClient=Newdefaulthttpclient (); HttpResponse Response=Httpclient.execute (HttpPost);    Httppost.releaseconnection (); //Verify the login success if the failure is not open after landing page//String memberpage = "http://192.168.33.160: 8088/hlslist.html ";String url="Http://192.168.33.160:8088/api/addhlslist?n1=shiyan7&n2=rtsp://admin:[email Protected]:554/1.sdp&n3 =0"; HttpGet HttpGet=Newhttpget (URL); Response= Httpclient.execute (HttpGet);//must be the same httpclient! httpentity entity =response.getentity (); String HTML= Entityutils.tostring (Entity,"GBK");    Httpget.releaseconnection (); System. out. println (HTML);} Public Static voidMain (string[] args) throws Clientprotocolexception, ioexception{Tset t=NewTset (); T.login ();}}

Java simulation Landing for yourself to see

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.