0

I am trying to get recharge plan information of service provider into my java program, the website contains dynamic data, and when i am fetching the URL using URLConnection i am only getting the static content,I want to automate the recharge plans of different website into my program.

package com.fs.store.test;
import java.net.*;
import java.io.*;

public class MyURLConnection 
{

    private static final String baseTataUrl = "https://www.tatadocomo/pre-paypacks";`enter code here`

    public MyURLConnection()
    {

    }

    public void getMeData() 
    {
        URLConnection urlConnection = null;
        BufferedReader in = null;
            try
                {
                    URL url = new URL(baseTataUrl);
                    urlConnection = url.openConnection();
                    HttpURLConnection connection = null;
                     connection = (HttpURLConnection) urlConnection;

                         in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()/*,"UTF-8"*/));
                         String currentLine = null;

                    StringBuilder line = new StringBuilder();

                         while((currentLine = in.readLine()) != null)
                         {  
                              System.out.println(currentLine);
                              line = line.append(currentLine.trim());
                         } 
                      }catch(IOException e)
                      {
                         e.printStackTrace();
                      }
                        finally{
                            try{
                                in.close();
                            }
                            catch(Exception e){
                                e.printStackTrace();
                            }
                        }
        } 

    public static void main (String args[])
    {
        MyURLConnection test = new MyURLConnection();
        System.out.println("About to call getMeData()");
        test.getMeData();
    }


}
2
  • 2
    Can we see the Java code that you have tried to read the HTML please. Commented Apr 2, 2014 at 11:33
  • Without the code it's hard to help you Commented Apr 2, 2014 at 11:35

2 Answers 2

1

You must use one of HtmlEditorKits with Javascript enabled in your browser and then get content. See examples: oreilly

Sign up to request clarification or add additional context in comments.

Comments

0

Inspect the traffjc. Firefox has a TamperData plugin for instance. Then you may communicate more directly.

Use apache's HttpClient to facilitate the communication, instead of plain URL.

Maybe use some JSON library if JSON data are coming back.

More details, but you might now skip some loading.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.