开发者

Info from the URL

I want to create an Application, the description of it as follows

  • Perform search
  • Display the results.

Basically, I want to create an application for an existing web-site which does this, but my need is to create for a Mobile.

Based on the website link, it refers to some ASP pages. for e.g. http://test.com/query.asp. The website allows the user to enter various input for search.

I want to create and then send the same request to the server and get the result. How can I know what all parameters/headers it is taking and what format is the response (XML or JSON).

Below is my sample code for the Android Device

            HttpClient httpclient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        List nameValuePairs = new ArrayList(3);
        //this is where you add your data to the post method
        nameValuePairs.add(new BasicNameValuePair("sel", "1"));
        nameValuePairs.add(new BasicNameValuePair("txt", "2466"));
        nameValuePairs.add(new BasicNameValuePair("selr", "2011"));
        httpPost.setEntit开发者_JAVA技巧y(new UrlEncodedFormEntity(nameValuePairs));
        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httpPost);
        content = response.getEntity().getContent();
        return content;

// Update Ok, now I am able to get the desired output from the web query. I printed the result for my Http Post request and I saw some HTML tags in it. In short, it prints the source of the HTML page that has to be displayed.

Is there a way to display the HTML view in my Android Application? Or a way to fetch only the relavant data from the response and ignore the HTML tags etc..?

First line of the response looks like

06-17 16:35:21.756: DEBUG/(30307): <script language="javascript" type=text/css>

//

Regards, Nirav


You need to speak with the owner/developer of the web site / service that you want to access. Only they can reliably tell you what their APIs are if you are unable to determine them yourself from WireShark captures.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜