So this may seem like a really simple question, but I haven't had any luck searching for it because it's also kind of specific.
I have a website, which i use WebView
, i called wv, to load it via wv.load(URL)
On the website, there are php forms, which will generate html tables when the user interacts with it (by clicking submit).
Since html table was generated, the source code for the html table was also generated, but the url stays the same. The newly generated source code that has html table in it is the one that i want to grab.
Please see my code below:
private final String URL = "http://google.com";
private WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wv = (WebView) findViewById(R.id.wvPage);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl(URL);
wv.setWebViewClient(new WebViewClient()
{
@Override
public void onPageFinished(WebView view, String url)
{
//view.loadUrl(URL);
new AsyncClass().execute(url);
Log.i("ASDF", "pagefinished");
}
});
}
I called the execute function everytime the form finish loading. Even with the tables generated, i still dont get the newly generated source code for the table. Below is my AsynTask implementation: I just copied it from another post.
@Override
protected Void doInBackground(String... URL)
{
try
{
HttpClient httpclient = new DefaultHttpClient(); // Create HTTP Client
HttpGet httpget = new HttpGet(URL[0]); // Set the action you want to do
HttpResponse response = httpclient.execute(httpget); // Execute it
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent(); // Create an InputStream with the response
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
Log.i("Source Code:", line);
}
String resString = sb.toString(); // Result is here
is.close();
}
catch (Exception ex){
ex.printStackTrace();
Log.i("ERROR", ex.toString());
}
return null;
}
All I want to do is get the new source code of the html table, so I can move on to parsing it. Any help is appreciated.