Skip to content
Snippets Groups Projects
Commit 0fd9a495 authored by am13g23's avatar am13g23
Browse files

Uploaded source code

parent 79a68d19
No related branches found
No related tags found
No related merge requests found
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;
class SotonLookupTool{
public static String ReadLine(String message){
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.print(message);
try {
return br.readLine();
} catch (Exception e) {
System.out.println(e);
return "";
}
}
public static String MakeHttpGetRequest(String URL){
return "";
}
public static void main(String[] args){
try {
String id = ReadLine("Enter id: ");
URL url = new URL("https://www.ecs.soton.ac.uk/people/" + id);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader br= new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
boolean found = false;
do {
line = br.readLine();
if (line != null){
if (line.length() >= 25){
//System.out.println(line.substring(0,25));
if (line.substring(0,25).equals("<meta property=\"og:title\"")){
System.out.print("Found: ");
System.out.println(line.substring(35,(line.length()-4)));
}
}
}
} while (line != null);
if (!found){
System.out.println("Not found");
}
}
catch (Exception e) {
System.out.println(e);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment