1
我需要从我的应用程序传递3下拉值到网站链接http://www.way2franchise.com/ 说:广告和媒体,选择投资,选择状态。是我的3个值。
我需要传递到搜索过滤器链接: http://www.way2franchise.com/search/filter_franchise。传递数据到服务器并接收它
P.S:我不能发布超过2个链接,因为受到了stackoverflow的限制。
在讨论有两个链接:
1.网站链接
2.搜索过滤器链接。
public class DatafetchingActivity extends Activity {
TextView result;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
result = (TextView) findViewById(R.id.result);
BufferedReader bufferedReader = null;
HttpClient httpClient = new DefaultHttpClient();
HttpPost request = new HttpPost("http://www.way2franchise.com/search/filter_franchise");
List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("p", "advertisement_and_media"));
postParameters.add(new BasicNameValuePair("q", "Select Industry"));
postParameters.add(new BasicNameValuePair("r", "Select Industry"));
try {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(
postParameters);
request.setEntity(entity);
HttpResponse response = httpClient.execute(request);
bufferedReader = new BufferedReader(new InputStreamReader(response
.getEntity().getContent()));
StringBuffer stringBuffer = new StringBuffer("");
String line = "";
String LineSeparator = System.getProperty("line.separator");
while ((line = bufferedReader.readLine()) != null) {
stringBuffer.append(line + LineSeparator);
}
bufferedReader.close();
result.setText(stringBuffer.toString());
Toast.makeText(DatafetchingActivity.this, "Finished",
Toast.LENGTH_LONG).show();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(DatafetchingActivity.this, e.toString(),
Toast.LENGTH_LONG).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(DatafetchingActivity.this, e.toString(),
Toast.LENGTH_LONG).show();
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
} 现在,此输出为搜索filter.Its的整个结果相同的输出,如同我复制并粘贴的搜索过滤器链接。
但这不是我想要的。
我需要的是,如果我打开链接(而不是搜索过滤器链接),并选择广告和媒体选项,选择投资,选择状态。我应该只根据传递的选项值得到结果。
我一无所知机器人编程,但你知道你有'“选择行业”'指定两次当您添加项目到'postParameters'列表? – Tinsa 2013-04-07 12:48:49
@MoonSire这是一个领域,所以这里没有问题。 – 2013-04-07 13:22:46