open url, wait until finished and parse

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

open url, wait until finished and parse

Postby The Spirit » Thu Apr 30, 2009 9:58 pm

HI.
I load a url with loadURL. Can i somehow find out, when the page is completely loaded.
I don´t need to display the url, but until now, i don´t know how to find out, when it is finished.
I would like to parse the sourcecode, when the page is completely loaded, for special words.
From there on, i need to load a new url, with some of this special words.
Is there any option to do this.
I come from python, and there i would read the data line by line and look for the special word.
But i don´t know how to do this in java.
Thx
The Spirit
Developer
Developer
 
Posts: 48
Joined: Fri Jan 02, 2009 1:59 pm
Location: Germany

Top

Postby padde » Fri May 01, 2009 9:53 am

Why are you using a webview when you dont want to display the url? :shock:
There are so many codes in this forum that show how to load stuff from net..
the search function must have been in camouflage mode again.. bad search function *slap*


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. String thedamnurl = "http://www.google.de"
  3.  
  4. DefaultHttpClient client = new DefaultHttpClient();
  5.  
  6. HttpResponse response;
  7.  
  8. HttpEntity entity;        
  9.  
  10. try {
  11.  
  12.     HttpGet get = new HttpGet(thedamnurl);
  13.  
  14.     response = client.execute(get);
  15.  
  16.     entity = response.getEntity();
  17.  
  18.     InputStream is = entity.getContent();
  19.  
  20.     // do stuff with is... what ever it is
  21.  
  22.     is.close();
  23.  
  24.     if (entity != null) entity.consumeContent();
  25.  
  26. } catch (Exception e) {}
  27.  
  28.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


The InputStream always cotains the full site except the server send a wrong content length.

Greets
Padde
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby The Spirit » Fri May 01, 2009 10:30 am

i just started with the webview in order to check wether my url is correct or not.
because i don´t use a default one. it has user input within it, so i tried this first.
thanks for your help

but how about parsing the html? couldn´t find any info on this
The Spirit
Developer
Developer
 
Posts: 48
Joined: Fri Jan 02, 2009 1:59 pm
Location: Germany

Postby padde » Fri May 01, 2009 1:31 pm

Hmm i would try it with XML parsing.. there are several tuts and examples here in
the forum.
But i think you have to add a the xml line first... would look like this i guess:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. String xmlstuff = "<?xml version='1.0' encoding='utf-8'?>";
  3.  
  4. InputStream is = new SequenceInputStream(new ByteArrayInputStream(xml.getBytes()), entity.getContent());
  5.  
  6.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


The resulting InputStream "is" should be parseable in the same way as shown in many examples here in the forum.


Greets
Padde
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby The Spirit » Mon May 11, 2009 1:22 pm

hi.
thanks for all the info.
one question about the httpget:
am i establishing a connect to the page containing my password and login? so if i will go on, will i be "logged" in on the page?
Thanks for help
The Spirit
Developer
Developer
 
Posts: 48
Joined: Fri Jan 02, 2009 1:59 pm
Location: Germany

Postby padde » Mon May 11, 2009 7:25 pm

If you send password and username u will be logged on.. but just for the session or as long
as the site stores the login information. I guess cookies are not stored on the device.. but i am
not 100& sure about that.
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests