The main problem I'm having is parsing from the website to my program. I got it to print out the source code. Also if it doesn't contain 'http://' I need to add it. I really don't understand how to parse strings .
import java.net.*;
import java.io.*;
import java.util.Scanner;
public class Project6 {
public static void main (String [] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.print("Please enter the URL. ");
String web= sc.nextLine();
String foo = "http://allrecipes.com/";
//is "web" have an allrecipes.com url?
//if it doesn't, then exit
if ( web.equals(foo)) {
StringBuilder s = new StringBuilder();
URL recipes = new URL (web);
BufferedReader in = new BufferedReader(new InputStreamReader(recipes.openStream()));
String inputLine;
while ((inputLine = in.readLine ())!= null)
System.out.println(inputLine);
in.close();
}
else {
System.out.println("I'm sorry, but that is not a valid allrecipes.com URL.");
System.exit(0);
//does "web" start with "http://"
//if it doesn't, add it
}