Advertisement
Guest User

Untitled

a guest
Sep 25th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class SearchEngine {
  4.     public static void main(String[] args) {
  5.         System.out.println("Creating Index and Scraping Pages");
  6.         // 1. Create a new Indexer object
  7.        
  8.         Indexer i = new Indexer();
  9.         String[] words = i.getWords(); // #3 in addPage
  10.  
  11.        
  12.         addPage(i, "http://pic.fsu.edu/");
  13.         addPage(i, "http://pic.fsu.edu/about.php");
  14.         addPage(i, "http://pic.fsu.edu/people.php");
  15.         addPage(i, "http://pic.fsu.edu/students.php");
  16.          
  17.        
  18.         /* 2. Use the addPage method from this class
  19.          *      to add the following websites to your index
  20.          *      http://pic.fsu.edu/
  21.          *      http://pic.fsu.edu/about.php
  22.          *      http://pic.fsu.edu/people.php
  23.          *      http://pic.fsu.edu/students.php */
  24.        
  25.         System.out.println("System ready for queries");
  26.        
  27.         /* 3. Open a input dialog using the JOptionPane class
  28.          *      and ask for a word to search the index.
  29.          *      Get the word to search for as a result String.
  30.          */
  31.        
  32.         String location = JOptionPane.showInputDialog(null, "Please insert a word to search: ");
  33.        
  34.        
  35.         // 4. Search the index for the word requested, get the result.
  36.        
  37.         String search = WebGet.httpget(location);
  38.        
  39.         /* 5. Output the search result either to the console
  40.          *      or using a JOptionPane message dialog.
  41.          */
  42.         JOptionPane.showMessageDialog(null, "Results for word search: " + location);
  43.         Page p = new Page(search);
  44.         printWords(p);
  45.     }
  46.    
  47.    
  48.    
  49.     public static void addPage(Indexer i, String location) {
  50.         // 1. Get the html code from the location provided to this method
  51.         // 2. Create a new page object and set its html code to the code you downloaded
  52.         // 3. Get the array of words from the page object. (getWords)
  53.         // 4. Add an entry to the indexer, providing the location and the array of words
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement