//package org.snancekivell.one_day_watcher;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.LinkedList;
public class site_utils {
public static final String ADDRESS_1_DAY = "http://www.1-day.co.nz/";
public static LinkedList getpage(){
LinkedList page = new LinkedList();
try{
URL url = new URL(ADDRESS_1_DAY);
InputStream is =url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line;
while ((line=reader.readLine())!=null){
page.add(line);
}
}
catch(Exception e){
e.printStackTrace();
System.exit(1);
}
return page;
}
public static LinkedList get_products(LinkedList page) {
LinkedList products= new LinkedList();
for (int i=0; i< page.size();i++){
if (page.get(i).contains(""))
{
i+=2;
String head1= page.get(i).trim().replace("", "");
i+=2;
String head2 = page.get(i).trim().replace("", "");
i+=16;
String price = page.get(i).replace("", "").replace(" ", "").trim();
products.add(head1+" : "+head2+" : "+price);
}
}
return products;
}
}