Results 1 to 4 of 4
  1. #1
    ZhiMing is offline Member
    Join Date
    Mar 2014
    Rep Power

    Question Getting data output from websites

    Is it possible to use Java to input data to website, and then get the output? For example, can you use java to input a word to and then get the data from the resulting webpage? I've noticed there are sometimes android applications where users of a website create an app version of the website, so presumably they are working on a similar principal of using java (for android applications) to inputting information (such as when you log into the website through the app) etc. and getting the same output information you would get if you inputted that information into the actual website itself.

    The real problem is:

    1. I'm not sure if I'm correct in assuming that this is all just java doing this or if there is some other programming language being implemented to achieve this result
    2. I don't know what terminology I should be using, as I'm not getting any results when I search on the web for how to do this

    Also, if this can be achieved, does anyone know of a good resource for a beginner to achieve this? Thanks! Any help would be much appreciated.

  2. #2
    AlexGraal is offline Señor Member
    Join Date
    Jan 2014
    Rep Power

    Default Re: Getting data output from websites

    For getting the output - I'm not sure, somebody else will have to answer.

    As for the input, the answer is simple.

    Take a look at, for example.

    The homepage is:

    If I search for the word "rough," it takes me to the page

    If I search for the word "talk," it takes me to the page

    It's that simple - on a lot of search websites, that is how it works.

    Wolfram alpha works in a similar way, with the input being tokenized by character, adding +s between the characters, and then adding it to the end of the link.

  3. #3
    ZhiMing is offline Member
    Join Date
    Mar 2014
    Rep Power

    Default Re: Getting data output from websites

    Thanks! Your answer helped a lot. I was actually able to find the information regarding getting output once I had done as you advised. In the end, I ended up making this method:

    Java Code:
    public String getWebData(String urlString, String add) throws IOException{
            String output = "";
            try {
    //+s being the token, for example if was being used
                add = add.replace(" ", "+s");
                urlString = urlString + add;
                URL url = new URL(urlString);
                InputStream inputStream = url.openStream();
                BufferedReader inputReader = new BufferedReader(new InputStreamReader(inputStream));
                StringBuffer webPageData = new StringBuffer();
                String inputLine = null;
                while ((inputLine = inputReader.readLine()) != null) {
                output = webPageData.toString();
            } catch (MalformedURLException ex) {
                Logger.getLogger(Functions.class.getName()).log(Level.SEVERE, null, ex);
            return output;
    I appreciate the help

  4. #4
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Tucson, AZ
    Rep Power

    Default Re: Getting data output from websites

    Read up on HTTP request methods. The most important ones for interacting with web pages are GET and POST, and sometimes PUT. Don't try to implement them yourself; there are plenty of good HTTP libraries available.

    Android apps that look like web pages may actually be web pages. There are app frameworks that are basically browsers with expanded versions of JavaScript that provide access to the phone hardware. Then you can develop your app as a web app and publish it inside the wrapper for Android, iOS, or whatever other platform you want to support.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. How to save the data from websites to DB??
    By sowmya1122sk in forum New To Java
    Replies: 0
    Last Post: 04-05-2013, 10:00 AM
  2. formatting data output
    By droidus in forum New To Java
    Replies: 16
    Last Post: 04-13-2011, 12:26 AM
  3. Accessing Data From Websites in Java
    By capitalistpig in forum New To Java
    Replies: 13
    Last Post: 06-21-2010, 11:11 PM
  4. help with data output, input
    By collin389 in forum New To Java
    Replies: 3
    Last Post: 11-11-2009, 06:34 PM
  5. Weird data output
    By Shaolin in forum New To Java
    Replies: 12
    Last Post: 12-11-2007, 05:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts