From 1909f442ab2feb0f22694ab8573015e97061b4c2 Mon Sep 17 00:00:00 2001 From: Jagw Date: Mon, 1 Nov 2010 11:35:30 +0000 Subject: Initial Commit of blasearch --- blasearch.class | Bin 0 -> 1855 bytes blasearch.java | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 blasearch.class create mode 100644 blasearch.java diff --git a/blasearch.class b/blasearch.class new file mode 100644 index 0000000..bbed588 Binary files /dev/null and b/blasearch.class differ diff --git a/blasearch.java b/blasearch.java new file mode 100644 index 0000000..8baad91 --- /dev/null +++ b/blasearch.java @@ -0,0 +1,73 @@ +/* + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* + Copyright 2010 Jamie Walters + based on code by Joe Robinson +*/ + + +import java.net.URL; +import java.net.URLConnection; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class blasearch { + + public static void main(String[] args) throws IOException + { + String query = args[0]; + String[] parts = null; + //URL which provides XML response + URL url = new URL("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q="+ query); + + URLConnection urlc = url.openConnection(); + + BufferedReader br = new BufferedReader(new InputStreamReader(urlc.getInputStream())); + String line; + String[] lines; + ArrayList results = new ArrayList(); + ArrayList urls = new ArrayList(); + String result = ""; + String tempString = ""; + //Read every line + while ((line = br.readLine()) != null) + { + // Splits the google output by the commas + lines = line.split(","); + + for(int i=0; i