1.å¦ä½ä½¿ç¨HttpClient
2.å¦ä½è·åç½ç«jså¾çå¦ä½è·åç½ç«jså¾ç
3.java关于在程序中实现网页操作的源码问题,坐等!源码大发平台源码
å¦ä½ä½¿ç¨HttpClient
ä¸ãç®ä»
HttpClientæ¯Apache Jakarta Commonä¸çå项ç®ï¼ç¨æ¥æä¾é«æçãææ°çãåè½ä¸°å¯çæ¯æHTTPåè®®ç客æ·ç«¯ç¼ç¨å·¥å ·å ï¼å¹¶ä¸å®æ¯æHTTPåè®®ææ°ççæ¬å建议ãHttpClientå·²ç»åºç¨å¨å¾å¤ç项ç®ä¸ï¼æ¯å¦Apache Jakartaä¸å¾èåçå¦å¤ä¸¤ä¸ªå¼æºé¡¹ç®CactusåHTMLUnité½ä½¿ç¨äºHttpClientã
äºãç¹æ§
1. åºäºæ åã纯åçjavaè¯è¨ãå®ç°äºHttp1.0åHttp1.1
2. 以å¯æ©å±çé¢å对象çç»æå®ç°äºHttpå ¨é¨çæ¹æ³ï¼GET,源码minix3源码 POST, PUT, DELETE, HEAD, OPTIONS, and TRACEï¼ã
3. æ¯æHTTPSåè®®ã
4. éè¿Http代ç建ç«éæçè¿æ¥ã
5. å©ç¨CONNECTæ¹æ³éè¿Http代ç建ç«é§éç.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.List;
import javax.net.ssl.SSLContext;
import org.apache.ment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN);
HttpEntity reqEntity = MultipartEntityBuilder.create().addPart("bin", bin).addPart("comment", comment).build();
ponentsseparatedbystring:@]];
if(murlarray.count=2){
[mUrlArrayremoveLastObject]ï¼
}
//urlResurltæ¯ææè·åå¾ççURLçæ¼æ¥ï¼MUrlArrayæ¯ææURLçæ°ç»ã
//ç¹å»jsæ·»å å¾ç
[mWebViewstringbyevaluatingjavascriptfromstring:@å½æ°registimageclickaction(){
varimgs=document.getElementsByTagName(img);varimgs=document.getelementsbytagname(img
varlength=imgs.length;varlength=imgs.length
for(varI=0ï¼æi){
img=imgs[I]ï¼
img.onclick=function(){
window.location.href=å¾åé¢è§:this.src}
}
}
[mWebViewstringbyevaluatingjavascriptfromstring:@registimageclickaction()ï¼
}
//å¨è¿ä¸ªæ¹æ³ä¸ï¼æè·å¾åçç¹å»äºä»¶å被ç¹å»å¾åçurlã
-(BOOL)webView:(UIWebView*)webViewshouldStartLoadWithRequest:(NSURLRequest*)请æ±å¯¼èªç±»å:(UIWebViewNavigationType)导èªç±»å{
//é¢è§å¾ç
å¦æ(ã请æ±ãURL.schemeisequaltostring:@å¾åé¢è§å¾åé¢è§:
path=[pathstringbyaddingpercentescapesusingcoding:nsuTF8stringencoding]ï¼
//pathæ¯è¢«ç¹å»å¾åçurlã
è¿åå¦ï¼
}
è¿åYES
}
åªäºæ¹æ³å¯ä»¥è·å/s?wd=WebDriver&ie=utf-8";
try {
HttpURLConnection httpUrlConnection = (HttpURLConnection) new URL(url).openConnection();
httpUrlConnection.setRequestMethod("GET");
httpUrlConnection.setUseCaches(true); //使用缓存
httpUrlConnection.connect(); //建立连接
InputStream inputStream = httpUrlConnection.getInputStream(); //读取输入流
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
String string;
while ((string = bufferedReader.readLine()) != null) {
System.out.println(string); //打印输出
}
bufferedReader.close();
inputStream.close();
httpUrlConnection.disconnect();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} //创建连接
}
}