android webview点击模拟

| 我想知道是否可以从网站加载框架,填充文本框,按提交按钮并从该页面获取结果?我需要在后台执行此操作,以便从不显示我的Web视图,仅显示一个edittext和一个textview ...     
已邀请:
您不能使用http请求来处理您提到的内容吗? 您需要WebView做什么?     
用户按下提交时,可以使用httpGet获取页面,并使用httpPost发布结果。您所需要做的就是确保帖子包含网页期望的数据,并采用期望的格式。 检查所需内容的一种好方法是使用Firefox Live HHTP标头(https://addons.mozilla.org/en-US/firefox/addon/live-http-headers/)。 例如,GET可能是
URI uri = new URI(<your URL here>);
HttpGet request = new HttpGet(uri);
HttpResponse response = defaultHttpClient.execute(request);
HttpEntity entity = response.getEntity();
String content = EntityUtils.toString(entity);
然后,使用编辑文本框和按钮等设置您的Android视图。当用户按下Submit(提交)时,您将从编辑文本框中获得文本,然后按如下所示构造POST。
URI uri = new URI(<your URL here - without a host>);
HttpPost request = new HttpPost(urri);
request.setHeader(\"Content-type\", \"application/x-www-form-urlencoded\");

List<NameValuePair> bodyParams = new ArrayList<NameValuePair>();
bodyParams.add(new BasicNameValuePair(<parameter name string>, <parameter value string>);
// repeat additional bodyParams.add() as necessary for further parameters
request.setEntity(new UrlEncodedFormEntity(bodyParams, HTTP.UTF_8));
HttpHost httpHost = new HttpHost(<your host here>);
HttpResponse response = defaultHttpClient.execute(httpHost, request);
HttpEntity entity = response.getEntity();
String content = EntityUtils.toString(entity);
    

要回复问题请先登录注册