Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class SearchEngine {
- public static void main(String[] args) {
- System.out.println("Creating Index and Scraping Pages");
- // 1. Create a new Indexer object
- Indexer i = new Indexer();
- String[] words = i.getWords(); // #3 in addPage
- addPage(i, "http://pic.fsu.edu/");
- addPage(i, "http://pic.fsu.edu/about.php");
- addPage(i, "http://pic.fsu.edu/people.php");
- addPage(i, "http://pic.fsu.edu/students.php");
- /* 2. Use the addPage method from this class
- * to add the following websites to your index
- * http://pic.fsu.edu/
- * http://pic.fsu.edu/about.php
- * http://pic.fsu.edu/people.php
- * http://pic.fsu.edu/students.php */
- System.out.println("System ready for queries");
- /* 3. Open a input dialog using the JOptionPane class
- * and ask for a word to search the index.
- * Get the word to search for as a result String.
- */
- String location = JOptionPane.showInputDialog(null, "Please insert a word to search: ");
- // 4. Search the index for the word requested, get the result.
- String search = WebGet.httpget(location);
- /* 5. Output the search result either to the console
- * or using a JOptionPane message dialog.
- */
- JOptionPane.showMessageDialog(null, "Results for word search: " + location);
- Page p = new Page(search);
- printWords(p);
- }
- public static void addPage(Indexer i, String location) {
- // 1. Get the html code from the location provided to this method
- // 2. Create a new page object and set its html code to the code you downloaded
- // 3. Get the array of words from the page object. (getWords)
- // 4. Add an entry to the indexer, providing the location and the array of words
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement