我試圖寫一個Android應用程序,這將讓我從一個網站,對我的工作名冊https://www.blahblahblahcompany.com/Rostering/exportRoster.aspxAndroid的HTTPS登錄
這是可能閱讀的文本?我能否通過網站驗證自己,然後下載源代碼?
有問題的網站上也有名冊問題 http://img528.imageshack.us/img528/9954/rosterf.png
我試圖寫一個Android應用程序,這將讓我從一個網站,對我的工作名冊https://www.blahblahblahcompany.com/Rostering/exportRoster.aspxAndroid的HTTPS登錄
這是可能閱讀的文本?我能否通過網站驗證自己,然後下載源代碼?
有問題的網站上也有名冊問題 http://img528.imageshack.us/img528/9954/rosterf.png
我不知道如果我得到你真正想做的事,但我敢肯定,至少,你會需要一些GET/POST操作來執行認證proccess和檢索數據/信息。請檢查下面的方法:
public StringBuilder post(String url, List<NameValuePair> nvps) {
try {
HttpPost httppost = new HttpPost(url);
// if there is cookies, set then
if (cookies != null && cookies.size() > 0) {
String cookieString = "";
for (int i = 0; i < cookies.size(); ++i) {
cookieString += cookies.get(i).getName() + "=" + cookies.get(i).getValue() + "; ";
}
cookieString += "domain=" + Constants.BaseUrl + "; " + "path=/";
httppost.addHeader("Cookie", cookieString);
}
// connection timeout options
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, Constants.timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, Constants.timeoutSocket);
// setup the post method
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
httppost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
HttpResponse response = httpClient.execute(httppost);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder builder = new StringBuilder();
for (String line = null; (line = reader.readLine()) != null;)
builder.append(line).append("\n");
// set cookies
List<Cookie> incomingCookies = httpClient.getCookieStore().getCookies();
for (int i = 0; incomingCookies != null && i < incomingCookies.size(); i++) {
cookies.add(incomingCookies.get(i));
}
return builder;
} catch (UnsupportedEncodingException e) {
} catch (ClientProtocolException e) {
} catch (IOException e) {
} catch (Exception e) {
}
return null;
}
上面mehod執行在URL字符串參數後,使用所述一對值nvps作爲用於報頭參數。需要注意的是常量類是正在爲您的WebService聲明靜態字符串(如API條目)類,和現場餅乾的是,該怎麼保持你的會話問題餅乾的列表。此方法將以字符串構建器對象的形式返回POST請求的結果。基本上,這是一種通用的方法,可以在多種情況下使用,而且您應該做適應性調整以適應任務。這是你可以用來認證。
還有另外一個重要的方法,在HTTP GET:
public StringBuilder get(String url) {
try {
HttpGet httpget = new HttpGet(url);
// if there is cookies, set then
if (cookies != null && cookies.size() > 0) {
String cookieString = "";
for (int i = 0; i < cookies.size(); ++i) {
cookieString += cookies.get(i).getName() + "=" + cookies.get(i).getValue() + "; ";
}
cookieString += "domain=" + Constants.BaseUrl + "; " + "path=/";
httpget.addHeader("Cookie", cookieString);
}
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, Constants.timeoutConnection);
HttpConnectionParams.setSoTimeout(httpParameters, Constants.timeoutSocket);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpResponse response = httpClient.execute(httpget);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder builder = new StringBuilder();
for (String line = null; (line = reader.readLine()) != null;)
builder.append(line).append("\n");
// set cookies
List<Cookie> incomingCookies = httpClient.getCookieStore().getCookies();
for (int i = 0; incomingCookies != null && i < incomingCookies.size(); i++) {
cookies.add(incomingCookies.get(i));
}
return builder;
} catch (UnsupportedEncodingException e) {
} catch (ClientProtocolException e) {
} catch (IOException e) {
} catch (Exception e) {
}
return null;
}
這一次做的步驟相似的序列,但有不同的用途。考慮到您已經通過身份驗證或者不需要身份驗證過程,這個目標的目標是檢索信息。它以字符串生成器的形式返回請求的數據。
請注意,除了這些方法都很一般,必須仔細檢查什麼是你所請求的網頁中使用的proccess。希望它能以某種方式幫助你! ;-)
導出爲.xls文件
截圖頁面在Android網頁瀏覽器,進入工具>選項>加密的能力>查看證書以查看支持的證書提供者列表。只要您從支持的供應商購買證書,您就可以做到這一點。 Here is a stack answer可能有一些線索。
我會嘗試澄清我想要的。 我希望能夠在我的用戶名和密碼輸入,然後從網站上下載源代碼或.xls文件,然後搜索我的名字的內容,然後將它後面的時間。 – mansonitefirefox