Java Reference
In-Depth Information
*/
public List<String> search(String session, String search,
String type)
throws IOException
{
String listType = "ul";
String listTypeEnd = "/ul";
StringBuilder buffer = new StringBuilder();
boolean capture = false;
List<String> result = new ArrayList<String>();
// build the URL
ByteArrayOutputStream bos = new ByteArrayOutputStream();
FormUtility form = new FormUtility(bos, null);
form.add("search", search);
form.add("type", type);
form.add("action", "Search");
form.complete();
URL url = new URL(
"http://www.httprecipes.com/1/8/menunc.php?session="
+ session);
URLConnection http = url.openConnection();
http.setDoOutput(true);
OutputStream os = http.getOutputStream();
// perform the post
os.write(bos.toByteArray());
// read the results
InputStream is = http.getInputStream();
ParseHTML parse = new ParseHTML(is);
// parse from the URL
advance(parse, listType, 0);
int ch;
while ((ch = parse.read()) != -1)
{
if (ch == 0)
{
HTMLTag tag = parse.getTag();
if (tag.getName().equalsIgnoreCase("li"))
Search WWH ::




Custom Search