-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoogleSuggest.java
38 lines (32 loc) · 1.1 KB
/
GoogleSuggest.java
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
35
36
37
38
/*
* Copyright (c) 2016 by Naohide Sano, All rights reserved.
*
* Programmed by Naohide Sano
*/
import java.util.List;
import vavix.util.screenscrape.annotation.Target;
import vavix.util.screenscrape.annotation.WebScraper;
/**
* GoogleSuggest.
*
* @see "http://so-zou.jp/web-app/tech/web-api/google/suggest/"
* @see "http://blog.shuffleee.com/1352/"
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (umjammer)
* @version 0.00 2016/02/24 umjammer initial version <br>
*/
public class GoogleSuggest {
/** query result as xml */
@WebScraper(url = "http://www.google.com/complete/search?q={0}&hl={1}&output={2}&ie={3}&oe={3}", isDebug = true)
public static class Result {
@Target("//toplevel/CompleteSuggestion/suggestion/@data")
String data;
public String toString() {
return "data: " + data;
}
}
/** @args 0: word */
public static void main(String[] args) throws Exception {
List<Result> data = WebScraper.Util.scrape(Result.class, args[0], "ja", "toolbar", "utf-8");
data.forEach(System.err::println);
}
}