Question: MUST BE DONE IN JAVA(data structures) Webpage: http://cis-linux2.temple.edu/~lafollet/2168/index.html Objective: I have placed into the examples folder a java program called WebPage.java which will demonstrate how

MUST BE DONE IN JAVA(data structures)

Webpage: http://cis-linux2.temple.edu/~lafollet/2168/index.html

Objective:

I have placed into the examples folder a java program called WebPage.java which will demonstrate how to open a URL and get the underlying html. Using this as a model, write a breadth first search to find all the pictures on my web pages. As you open a page, search for all the anchors where "somethingorother" is a string containing the name of a new web page. If (and only if) the "somethingorother" begins with "./" e.g. "./personal" and if it is a page you have not already visited, then enqueue it. Next, search for all the images on the page currently open. Images start with the tag

Webpage.java code

import java.io.*; import java.net.*;

public class WebPage { public static void reader(String where) { URL myURL = null; URLConnection myURLConnection = null; BufferedReader in = null; try { myURL = new URL(where); myURLConnection = myURL.openConnection(); myURLConnection.connect();

in = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream())); } catch (MalformedURLException e) { System.out.println(e); System.exit(1); } catch (IOException e) { System.out.println(e); System.exit(1); } String inputLine; try { while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); } in.close(); } catch (MalformedURLException e) { System.out.println(e); System.exit(1); } catch (IOException e) { System.out.println(e); System.exit(1); } }

public static void main(String args[]) { reader("http://cis-linux2.temple.edu/~lafollet"); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!