The goal of this assignment is to write a program that will

The goal of this assignment is to write a program that will scan a web page and harvest as many email addresses as possible. Many of these email address will be obfuscated in some way. It

Solution

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;


public class FindEmails {
   public static void main(String args[]) throws MalformedURLException, IOException{
       Scanner in = new Scanner(System.in);
       String url = \"https://cs1110.cs.virginia.edu/emails.html\";
       Scanner web = new Scanner(new URL(url).openStream());
       String wholePage = \"\";
       while(web.hasNextLine()) {
           wholePage += web.nextLine() + \"\ \";
       }
       int ind = 0, ind1 = 0, ind2 = 0, ind3 = 0;
       while(ind != -1){
           ind = wholePage.indexOf(\"@\", ind1);
           ind1 = wholePage.indexOf(\" \", ind);
           if(ind1 == -1){
               break;
           }
           ind2 = wholePage.lastIndexOf(\" \", ind);
           if(ind2 == -1){
               break;
           }
           String email = wholePage.substring(ind2, ind1 + 1);
           System.out.printf(\"Found: <%s>\ \", email);
       }
   }
}


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site