jazk0
asked on
HTML Parsing
Hello everyone i have a function which made an post request and getting the response html in string
the html is like that
I need a way to get DATA1 DATA2 DATA3 and URLDATA into vector array
I need the code for android app but it is Java
String sourceUrlString="http://www.url.com";
String result = postData(sourceUrlString);
public String postData(String url){
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("p", "bm02new"));
nameValuePairs.add(new BasicNameValuePair("town", "¿¿¿¿¿"));
nameValuePairs.add(new BasicNameValuePair("addr", ""));
nameValuePairs.add(new BasicNameValuePair("code", "0"));
nameValuePairs.add(new BasicNameValuePair("bank", "0"));
nameValuePairs.add(new BasicNameValuePair("submit", "ok"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
InputStream is = response.getEntity().getContent();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(20);
int current = 0;
while((current = bis.read()) != -1){
baf.append((byte)current);
}
/* Convert the Bytes read to a String. */
String text = new String(baf.toByteArray());
return text;
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
String text = null;
return text;
}
the html is like that
<html>
<head>
......
</head>
<body>
.......
.......
<table cellspacing="0" cellpadding="2" border="0">
<tbody>
<tr bgcolor="#3493e0">
<td width="90">
<img height="1" width="90" border="0" src="space.gif"><br>
<span class="smallw"><b>¿¿¿¿¿¿¿¿<br> ¿¿¿¿¿</b></span>
</td>
<td><img height="1" width="10" border="0" src="space.gif"></td>
<td width="160"><img height="1" width="160" border="0" src="space.gif"><br>
<span class="smallw"><b>¿¿¿¿¿</b></span>
</td>
<td><img height="1" width="10" border="0" src="space.gif"></td>
<td width="145"><img height="1" width="145" border="0" src="space.gif"><br>
<span class="smallw"><b>¿¿¿¿¿</b></span></td>
<td><img height="1" width="10" border="0" src="space.gif">
</td>
<td width="125"><img height="1" width="125" border="0" src="space.gif"><br>
<span class="smallw"><b>¿¿¿¿¿¿, ¿¿¿¿¿¿¿¿¿<br> 14.06.2010, 18:00</b></span>
</td>
</tr>
<tr height="42" bgcolor="#eeeeee">
<td><span class="normal">[b]DATA1[/b]</span></td>
<td></td>
<td><span class="normal">[b]DATA2[/b]</span></td>
<td></td>
<td><span class="normal">[b]DATA3[/b]</span></td>
<td></td>
<td align="center">
<span class="small"><a href="[b]URLDATA[/b]" onclick="window.open('','bmDetails056118','toolbar=no,location=no,menubar=no,directories=no,status=no,resizable=no,scrollbars=no,width=400,height=600, titlebar=no');" target="bmDetails056118"><img border="0" src="/magnifier.gif" alt="¿¿¿¿¿¿"></a></span></td>
</tr>
<tr height="42" bgcolor="">
<td><span class="normal">[b]DATA1[/b]</span></td>
<td></td>
<td><span class="normal">[b]DATA2[/b]</span></td>
<td></td>
<td><span class="normal">[b]DATA3[/b]</span></td>
<td></td>
<td align="center"> <span class="small"><a href="[b]URLDATA[/b]" onclick="window.open('','bmDetails643001','toolbar=no,location=no,menubar=no,directories=no,status=no,resizable=no,scrollbars=no,width=400,height=600, titlebar=no');" target="bmDetails643001"><img border="0" src="/magnifier.gif" alt="¿¿¿¿¿¿"></a></span></td>
</tr>
...............
...............
...............
</tbody>
</table>
I need a way to get DATA1 DATA2 DATA3 and URLDATA into vector array
I need the code for android app but it is Java
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Some suggestions - http://stackoverflow.com/questions/457684/reading-html-file-to-dom-tree-using-java
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello Valeri "<span class="small">" is surrounding all the data that i need but how can i get them into vector array can you give me a piece of code
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.