-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpaceCadets1.java
More file actions
34 lines (26 loc) · 1.03 KB
/
Copy pathSpaceCadets1.java
File metadata and controls
34 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class SpaceCadets1 {
public static void main(String args[]) throws IOException {
System.out.println("Enter the username of user:\n");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String email = br.readLine();
URL url = new URL ("http://www.ecs.soton.ac.uk/people/" + email);
BufferedReader br2 = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while ((inputLine = br2.readLine()) != null) {
if (inputLine.contains("<h2 class=\"uos-sia-title\" id=\"uos-sia-page-title\">")) {
String[] split = inputLine.split("<h2 class=\"uos-sia-title\" id=\"uos-sia-page-title\">");
String[] split2 = split[1].split("</h2>");
String name = split2[0];
if (!name.toLowerCase().contains("ecs people")) {
System.out.println("\nThe given user's name is " + name);
} else {
System.out.println("\nUser not found");
}
}
}
}
}