Write a simple java code for the following question:
Access a website of your choice with a comparison chart or any table of information.
Input: Name or any string to search for in a row.
Output: Description or another information about the given name in the same row
For example, in this website: http://www.tabletpccomparison.net/
Sample input (name): Microsoft Surface Pro 3
Sample Output(OS): Win 8.1 Pro
OR
Sample input (name): Sony Xperia Z2
Sample Output(OS): Android 4.4
Solution
import java.util.Scanner;
/**
*
* @author prmsh
*/
public class ReadWebsite {
public static void main(String args[]) throws MalformedURLException, IOException {
// stroring URL
String url = \"http://www.tabletpccomparison.net/ \";
Parser parser = new Parser(url);
NodeList movies = parser.extractAllNodesThatMatch(
new AndFilter(new TagNameFilter(\"table\"),
new HasAttributeFilter(\"class\", \"tableJX2 tableJX\")));
Scanner sc = new Scanner(System.in);
System.out.println(\"Enter input(name): \");
String input = sc.nextLine();
String result = movies.find(input);
System.out.println(\"Result: \"+result);
}
}
.