Google에서 검색 한 결과가 50 개가 아닙니다.Google을 통해 50 개의 검색 결과가 검색되었습니다.
public static List Retrieve(String entry){
List entryList = new ArrayList();
try {
// string new entry is making the keywords into query that can be known by google
String newEntry = (java.net.URLEncoder.encode(entry, "UTF-8").replace("+", "%20"));
// inputing the keywords to google search engine
URL url = new URL("http://www.google.co.id/search?q=" + newEntry + "&hl=en&num=10&lr=&ft=i&cr=&safe=images&tbs=");
// makking connection to the internet
URLConnection urlConn = url.openConnection();
urlConn.setUseCaches(false);
urlConn.setRequestProperty("User-Agent", "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)");
// getting the input stream of page html into bufferedreader
BufferedReader buffReader = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
String line;
StringBuffer buffer = new StringBuffer();
// getting the input stream of html into stringbuffer
while ((line = buffReader.readLine()) != null) {
buffer.append(line);
}
// finding the links
Pattern p = Pattern.compile(GOOGLE);
Matcher m = p.matcher(buffer.toString().toLowerCase());
while (m.find()) {
String link = m.group(0);
// putting the links of google search into list
entryList.add(link);
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
return entryList;
}
을하지만 그것은 단지 단지 10의 결과를 보여줍니다
나는 이것을 사용하고 있습니다.
데이터를 어떻게 검색합니까? –
음, 검색 용어를 입력하고 검색을 통해 수백만 가지 결과를 얻을 수 있습니다 ... 진지하게, 어떻게 그 결과를 검색하려고합니까? 코드를 보여줄 수 있습니까? – Thomas
Google의 ToS (http://www.google.com/accounts/TOS) (즉, 항목 5.3)를 위반하는 50 개 결과 – Carlo