Modify Listing 12.18 WebCrawler.java to search for the wordComputer Programming starting from the URL http://cs.armstrong.edu/liang . ?Your
Question:
Modify Listing 12.18 WebCrawler.java to search for the wordComputer Programming starting from the URL http://cs.armstrong.edu/liang. ?Your program terminates once the word is found. Display the URL for the page that contains the word.
Listing
Transcribed Image Text:
1 import java.util.Scanner; 2 import java.util.ArrayList; 3 4 public class WebCrawler { 5 public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); System.out.print("Enter a URL: "); String url = input.nextline(); crawler(url); / Traverse the Web from the a starting url 10 11 12 public static void crawler(String startingURL) { ArrayList
1 import java.util.Scanner; 2 import java.util.ArrayList; 3 4 public class WebCrawler { 5 public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); System.out.print("Enter a URL: "); String url = input.nextline(); crawler(url); / Traverse the Web from the a starting url 10 11 12 public static void crawler(String startingURL) { ArrayList list0fPendingURLS = new ArrayList<>(); ArrayList list0fTraversedURLS = new ArrayList<>(); 13 14 15 list0fPendingURLs.add(startingURL); while (!list0fPendingURLs.isEmpty() && list0fTraversedURLs.size() <= 100) { String urlString = list0fPendingURLs.remove(0); if (!list0fTraversedURLS.contains(urlString)) { listofTraversedURLs.add(ur1String); System.out.println("Crawl " + urīString); 16 17 18 19 20 21 24 25 26 for (String s: getSubURLS(ur1String)) { if (!list0fTraversedURLS.contains(s)) list0fPendingURLs.add(s); 27 28 29 30 31 32 33 public static ArrayList getSubURLs(String urlString) { ArrayList list = new ArrayList<>(); 34 35 try { java.net.URL url = new java.net.URL (urlString); Scanner input = new Scanner(url.openStream()); int current = 0; while (input.hasNext()) { String line = input.nextLine(); current = line.index0f("http:", current); while (current > 0) { int endIndex = line.indexOf C"\"", current); if (endIndex > 0) { // Ensure that a correct URL is found list.add(line.substring(current, endIndex)); current = line.indexOf("http:", endIndex); 36 37 38 39 40 41 42 43 44 45 46 47 222N 222 223 333 333 333 444 444 44
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (6 reviews)
Program Plan Create a class SearchWeb Declare searchWord startingURL of type Strings Implement the m...View the full answer
Answered By
Somshukla Chakraborty
I have a teaching experience of more than 4 years by now in diverse subjects like History,Geography,Political Science,Sociology,Business Enterprise,Economics,Environmental Management etc.I teach students from classes 9-12 and undergraduate students.I boards I handle are IB,IGCSE, state boards,ICSE, CBSE.I am passionate about teaching.Full satisfaction of the students is my main goal.
I have completed my graduation and master's in history from Jadavpur University Kolkata,India in 2012 and I have completed my B.Ed from the same University in 2013. I have taught in a reputed school of Kolkata (subjects-History,Geography,Civics,Political Science) from 2014-2016.I worked as a guest lecturer of history in a college of Kolkata for 2 years teaching students of 1st ,2nd and 3rd year. I taught Ancient and Modern Indian history there.I have taught in another school in Mohali,Punjab teaching students from classes 9-12.Presently I am working as an online tutor with concept tutors,Bangalore,India(Carve Niche Pvt.Ltd.) for the last 1year and also have been appointed as an online history tutor by Course Hero(California,U.S) and Vidyalai.com(Chennai,India).
4.00+
2+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Modify Listing 14.21, ClockPane.java, to add the animation into this class and add two methods start() and stop() to start and stop the clock. Write a program that lets the user control the clock...
-
Modify Listing 18.8, TowerOfHanoi.java, so that the program finds the number of moves needed to move n disks from tower A to tower B. Listing 1 import java.util.Scanner; 2 3 public class Tower0fHanoi...
-
Modify Listing 18.2, ComputeFibonacci.java, so that the program finds the number of times the fib method is called. Listing 1 import java.util.Scanner; 2 3 public class ComputeFibonacci { 4 /** Main...
-
A parallel-plate capacitor with circular plates of radius 0.10 m is being discharged. A circular loop of radius 0.20 m is concentric with the capacitor and halfway between the plates. The...
-
Repeat Exercise 27 with And 0 2 7 2 1
-
Convert the following binary fractions to decimal a) 100001.111 b) 111111.10011 c) 1001100.1011 d) 10001001.0111
-
CMS is a claims processing company in Mobile, Alabama. Chastity Jones, a black woman, completed an online employment application for a customer service position with CMS. Jones interviewed with a...
-
After six months of study, much political arm wrestling, and some serious financial analysis, Dr. Martin Starr, president of Southwestern University, had reached a decision. To the delight of its...
-
Country A is endowed with 18 units of good x and 1 unit of good y, while country B is endowed with 2 units of good x and 7 units of good y. Both countries consume x and y in fixed and equal...
-
Salary is hypothesized to depend on educational qualification and occupation. To understand the dependency, the salaries of 40 individuals [SalaryData.csv] are collected and each person's educational...
-
Write the following method that returns the maximum value in an ArrayList of integers. The method returns null if the list is null or the list size is 0. public static Integer max(ArrayList list)...
-
Write a program that uses the files described in Programming Exercise 12.31 and displays a ranking summary table for the first five girl?s and boy?s names as follows: The popularity ranking of baby...
-
Rutter Nursery Company packages its pine bark mulch in 50-pound bags. From a long history, the production department reports that the distribution of the bag weights follows the normal distribution...
-
Q3 Question 3 Key concepts in Corporations Law (10 marks) Why was Mr Salomon successful in his court case in Salomon v Salomon(1897)? What did the court say about the legal nature of a corporation?
-
In January of 2000, you started saving R100 per month in a fixed-interest savings account. You plan to withdraw all your savings from this account at the end of December 2023. How much will this...
-
What is lockout/tagout? Explain.
-
Wilson, Inc. provides the following data: 2017 2016 Cash $41,000 $25,000 Accounts Receivable, Net 128,000 62,000 Merchandise Inventory 71,000 50,000 Property, Plant, and Equipment, Net 195,000...
-
Dan's Dependable Delivery began the year with 30,000 $1 Common shares issued and outstanding. Paid in Capital in Excess of Par was $25,000 and Retained Earnings were $175,000. Net Income for the...
-
Ellis issues 6.5%, five-year bonds dated January 1, 2017, with a $250,000 par value. The bonds pay interest on June 30 and December 31 and are issued at a price of $255,333. The annual market rate is...
-
Reichenbach Co., organized in 2018, has set up a single account for all intangible assets. The following summary discloses the debit entries that have been recorded during 2018 and 2019. Instructions...
-
Which of the following statements is true? a. JavaFX cannot be used with Swing projects. b. JavaFX uses HTML for design layout. c. JavaFX can be used to develop applications for the desktop and the...
-
Fxml is ____________. A. A low-level declarative language b. An xml-based markup language c. Not as easy to use as swing to create the ui d. Dependent on explicit commands that must be performed in a...
-
The init() method is used for ____________. A. Pausing a javafx application B. Extending the application class C. Constructing a specified instance of the application class D. Performing...
-
Write a program in Ruby to find all prime numbers within a given range using the Sieve of Eratosthenes algorithm.
-
Question 1 [CLO 2] For the following transactions pass journal entries, prepare ledger accounts and also prepare the trial balance. 2018 April 1. Saeed started business with cash $200,000, stock...
-
i have written an informational interview e-mail to female television host and meet her to get to learn out of her. After a meeting i wants to thank her for sharing her time and knowledge to me. how...
Study smarter with the SolutionInn App